我是新来的斯卡拉很抱歉,如果这很容易,但我很难找到答案。一些操作员问题
我很难理解什么< - 做,什么()=>单位。我对这些的理解是 - >有时用在foreach中,而那个=>用在地图中。尝试谷歌“斯卡拉” < - ”不能证明卓有成效我发现http://jim-mcbeath.blogspot.com/2008/12/scala-operator-cheat-sheet.html,但它并不像乍看上去一样有用
val numbers = List("one", "two", "three","four","five")
def operateOnList() {
for(number <- numbers) {
println(number + ": came out of this crazy thing!")
}
}
def tweener(method:() => Unit) {
method()
}
tweener(operateOnList)
你看过http://docs.scala-lang.org/tutorials/FAQ/finding-symbols.html吗? – soc