MEAP 11/02/2010
Third paragraph:
Orig:
"Because we havent specified anything on the left side of the arrow, it means that the function were expecting as a parameter doesnt take any parameter for itself"
This was missleading to me. I also know the () => Unit notation.
e.g.
> val f = (g )=>Unit) => {println("begin f" ; g(); println("end f" }
f: (() => Unit) => Unit = <function1>
scala> val h : () => Unit = () => {println("begin h" ; println("make side effect" ; println("end h" }
h: () => Unit = <function0>
scala> f(h)
begin f
begin h
make side effect
end h
end f
Thus I could specify () on the left side and give "no" parameter to h (well actually it's the only value of type Unit "()" ), which passes the above criteria if () is interpreted as empty parameter list.
My humble suggestion:
Maybe a hint (footnote, box) to not mix call-by-name up with "()=>" because... would avoid this confusion (to me). Corrected MEAP version
Message was edited by: lutzhank
|