I have written two helloWorld functions, one with parentheses()
and another, without.
If I invoke the one with parameters, either specifically with parameters or without, it works fine. The other one defined without parameters cries foul "unit does not take parameters
". I am confused.
scala> def hWorld() = println("Hello World")
hWorld: ()Unit
scala> def hWorld = println("Hello World")
hWorld: Unit
scala> hWorld
Hello World
scala> hWorld()
<console>:10: error: Unit does not take parameters
hWorld()
^
scala> def hWorld2() = println("Hello World")
hWorld2: ()Unit
scala> hWorld2
Hello World
scala> hWorld2()
Hello World
scala>