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.

Reply via email to