Is there a more idiomatic way to execute a function upon its definition in Scala? Can I do better than the following Function1
definition with its immediate execution?
scala> (new Function1[Int, Int] { def apply(v1: Int) = v1 }) (5)
res0: Int = 5
Are there use cases that justify such calls? I have none, but got curious after I'd been asked about it and thought it might be helpful to find out.