Question

The Scala Style Guide suggests omitting parenthesis when invoking an Arity-0 function if and only if that function has no side effects.

What about when creating a new object? That is, is val myc = new MyClass or val myc = new MyClass() preferred?

Was it helpful?

Solution

I don't think its mentioned explicitly, but elsewhere in the style guide they show creating objects as part of other examples, and they use new MyClass

Eg, on this page: http://docs.scala-lang.org/style/naming-conventions.html

Plus that's the way I do it, so what else do you need :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top