Having two simple classes taking Int as an argument:
case class Foo(i: Int)
class Bar(j: Int)
I can say:
List(1,2,3) map Foo
Which works fine and is equivalent to a bit more verbose:
List(1,2,3) map {Foo(_)}
However Bar (because it is not a case class?) cannot be used in the same construct:
List(1,2,3) map Bar
error: not found: value Bar
List(1,2,3) map Bar
^
Is there some special syntax to reference any constructor and take advantage of eta expansion? List(1,2,3) map {new Bar(_)} seems a bit more verbose compared to Foo.
new String _, for example. It is also different at the bytecode level, and there's all sort of differences in JVM expectations between methods and constructors.