Comment on Martin Odersky (Scala creator) launches company to commercialize scala and akkaparentComments−fhars15yOnly the first two mean the same thing, and that is not syntactic sugar, but syntax error: error: identifier expected but '(' found. What you probably meant is that a b c and a.b(c) are the same thing. And admire the effect of the semicolons in http://article.gmane.org/gmane.comp.lang.scala.debate/2231−runT1ME15yAll three can be used for the same functionality:scala> object Test { | def myMethod( f:(String,String)=>String) { | println("MyMethod result =" + f("a", "b")) | } | } defined module Testscala> Test.myMethod( _ + "&" + _ ) MyMethod result =a&bscala> Test.myMethod( (a,b)=> a+"&"+b ) MyMethod result =a&bscala> Test.myMethod { (a,b)=>a+"&"+b } MyMethod result =a&b
Comments
Only the first two mean the same thing, and that is not syntactic sugar, but syntax error:
What you probably meant is that and are the same thing. And admire the effect of the semicolons in http://article.gmane.org/gmane.comp.lang.scala.debate/2231All three can be used for the same functionality:
scala> object Test { | def myMethod( f:(String,String)=>String) { | println("MyMethod result =" + f("a", "b")) | } | } defined module Test
scala> Test.myMethod( _ + "&" + _ ) MyMethod result =a&b
scala> Test.myMethod( (a,b)=> a+"&"+b ) MyMethod result =a&b
scala> Test.myMethod { (a,b)=>a+"&"+b } MyMethod result =a&b