Hi Saifi, When you give a result expression at the end of the block it gets evaluated. It first searches if there are any other such calls within the block and executes them in the same order. i.e., it pushes the calls first max(9) on the stack and then max(3) then its clear what happens...
But my point of concern is what if there is no result expression at the end of block the compiler does'nt care look for max method call.So why this behaviour?? thanks, SMS On Sat, Jun 20, 2009 at 3:21 PM, Saifi Khan <[email protected]>wrote: > > > On Sat, 20 Jun 2009, Rajkumar Goel wrote: > > > From: Mukund Deshpande > > > > > > > scala> def g():Unit={ > > | max(3) > > | def max(x:Int){ > > | println(x) > > | } > > | } > > <console>:6: error: block must end in result expression, not in > definition > > } > > ^ > > Now when you see this you will expect that at the end of max block you > will > > have to give some expression to evaluate...but i had given it earlier. > > > > What about this code ? Why does this compile and run ? > > def g():Unit = { > def max(x:Int) { > println(x) > } > max(3) > } > > thanks > Saifi. > > [Non-text portions of this message have been removed]

