The Scala front page says
Functions are first-class objects. Compose them with guaranteed type safety. Use them anywhere, pass them to anything.
But I can't seem to store a function in a val
like I would with other first-class objects in Scala.
scala> def myFunction = { println("hello world") }
myMethod: Unit
scala> myFunction
hello world
scala> val myVal = myFunction
hello world
myVal: Unit = ()
scala> myVal
scala>
What is the right way to do this?