scala - 在 Scala 中 => 是什么?

标签 scala

关闭。这个问题是opinion-based .它目前不接受答案。












想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题.

10 个月前关闭。




Improve this question




我知道 =>在 Scala 中用于函数字面量,意思是“将左边的东西转换成右边的东西”。但是这个符号实际上叫什么?等于,暗示,lambda?什么?

最佳答案

我记得在某处读过“火箭”这个词,可能是在书 Programming Scala 中。作者:Dean Wampler 和 Alex Payne。我找到了 this related answer from Bill Venners on a forum :

I asked Martin Odersky a while back what he called this, and he said "right arrow". Ron Hitchens suggested the name "bullet" to me a couple months ago. I used that here and there, but it didn't seem to stick. About 2 weeks ago I asked some Ruby guys what they call it, and they said "hash rocket". The reason for "hash" is Ruby uses it for mapping keys to value, i.e., "key => value" in Ruby is like "key -> value" in Scala (but untyped in Ruby), and of course -> in Scala is a library abstraction, not part of the language.

So I suggest we call it "rocket". It's more exciting and less violent than bullet, and we can put an adjective in there to differentiate the various uses in Scala: there's "function rocket" in anonymous functions, maybe a "case rocket" in a case clause in match expression or partial function, etc.


所以奥德斯基使用的“官方”术语是“右箭头”。

关于scala - 在 Scala 中 => 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14129237/

相关文章:

java - MongoDB。从数据库中提取整数。 java.lang.Integer 无法转换为 java.lang.String

scala - 是否可以知道在 Scala 中是否提供了默认参数作为实际参数值(当它们相等时)?

java - 如何读取和写入多个子文件夹?

scala - 如何获得当前工作中使用的核心数?

java - DataStax Cassandra 找不到 Logback-Classic

Scala:如何使 toString() 接受隐式参数?

session - 没有 cookie 的 Scalatra session

java - 构建成功时出现奇怪的 Maven 错误消息

scala - 如何识别远程 Actor ?

scala - 在编译时添加两个相同大小的列表