What is the difference between def foo = {} and def foo() = {} in Scala?

If you include the parentheses in the definition you can optionally omit them when you call the method. If you omit them in the definition you can’t use them when you call the method. scala> def foo() {} foo: ()Unit scala> def bar {} bar: Unit scala> foo scala> bar() <console>:12: error: Unit does not … Read more