compiler-theory

Scala “<-” for comprehension

萝らか妹 提交于 2019-11-26 05:22:46
问题 I have found that Scala always has a \"natural explanation\" to anything. Always something like \"ohh, but that\'s just a function being called on this and that object with this and that parameter\". In a sense, nothing is really compiler-magic as we know it from other languages. My question is on the <- operator as used in the following code: for(i <- 0 to 10) println(i) In this example I can see it being rewritten to something like: 0.to(10).foreach((i:Int)=>println(i)) but this doesn\'t