obj.( (a, b) => a + "." + b)
obj.(_ + "." + _)
obj { (a,b) => a + "." + b }
Seems to me that's syntactic sugar. The flexibility of Scala is the source of my love/hate relationship with the language. That being said, it's still my favorite thing to code in when I get the opportunity...You can code a domain specific options parser in scala so that your final code actually looks like this -
"@ $20 spot, price 5 calls, @ $25 strike, 59 days to expiry"
This is as simple as it can get. In fact, the senior quants literally say the above line word for word. So its practically English. Can't get any simpler than that.
Reference: http://www.scala-lang.org/node/1403
Of course code is hard to read if you don't know the language.
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/2231scala> 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
case class Lol (a: Int, b: Int)
Lol(2, 3) match {
case x Lol y => x
}also, portions of the scala api are a work in progress. constructs for multidimensional arrays have changed several times.
i may recommend the wampler book when they come out with a rewrite, say in a few months time. Now it seems too rushed. Some of it reads like a collection of blogposts.
Also wampler's idea of functional programming is very basic. No details on commonly used functional data structures or functional pgmming algorithms. More like "functional pgmming is X as opposed to OO pgmming is Y".
Okasaki's book ( http://news.ycombinator.com/item?id=1138979 ) needs to be written in Scala. That'll sell a boatload of copies. Even a modest attempt at that would work for a start. That's an awesome book.