scala - 为什么不推荐使用符号 "/:"

标签 scala

自从迁移到 scala 2.12.10 后,我在代码中收到警告,告诉我符号“/:”已被弃用,我应该改用 foldLeft。

为什么它已被弃用?我原以为这会产生更麻烦的代码。

最佳答案

它是简化 Scala 工作的一部分。 Here is what Martin Odersky had to say about it :

Another example, where I have doubts if not regrets are the /: and :\ operators in scala.collections. They are cute synonyms for folds, and I am still fond of the analogy with falling dominoes they evoke. But in retrospect I think maybe they did give a bad example for others to go overboard with symbolic operators.



这是弃用它的公关:https://github.com/scala/scala/pull/4893 .
这里还发生了一些进一步的讨论:https://github.com/scala/bug/issues/9607

关于scala - 为什么不推荐使用符号 "/:",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58709256/

相关文章:

java - Oracle jdbc "createArray"在尝试将数组传递给准备好的语句时抛出 "Unsupported feature"异常

scala - 检查集合中的所有项目是否与 Scala 中的谓词匹配

scala - 验证数字序列是否在允许的范围内

scala - 具有Java库的Scala Gradle控制台应用程序

scala - kafka directstream dstream map 不打印

scala - 如何在案例类的每个字段上应用函数

scala - Play 2.0 Scala教程-Heroku因进化而失败

scala - 在 Scala 中向 + 运算符添加空格会产生不同的结果?

scala - 如何在隐式搜索期间自动剥离 Scala 特征?

scala - Play (Scala)在同一 Action 中处理不同的内容类型