Frage

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?

War es hilfreich?

Lösung

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 :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top