Notes.sublime.org
Personal postings.
back to main site
 

June 26, 2008

I spent some time today having syntax problems with scala function by-name function declarations. It turns out that a space after the colon is critical. In the end someone on the scala irc channel at irc.freenode.net. by the name of ‘mapreduce’ helped me out (thanks!).

This session should clarify what works and what doesn’t work:

scala> def some1 [T] (interval :int) (f :() =>T) (noContent:T) = {}   
some1: [T](int)(() => T)(T)Unit

scala> def some2 [T] (interval :int) (f :=>T) (noContent:T) = {}  
<console>:1: error: ':' expected but identifier found.
def some2 [T] (interval :int) (f :=>T) (noContent:T) = {}
^
<console>:1: error: identifier expected but eof found.
def some2 [T] (interval :int) (f :=>T) (noContent:T) = {}
^

scala> def some2 [T] (interval :int) (f : =>T) (noContent:T) = {}
some2: [T](int)(=> T)(T)Unit

scala> def some3 [T] (interval :int) (f: =>T) (noContent:T) = {}
some3: [T](int)(=> T)(T)Unit

Comments
blog comments powered by Disqus