質問

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?

役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top