문제

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