自从迁移到 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/