Hi!
I have a question about the code conventions in Scala, or more specifically, about methods without parenthesis. For example, the ExecutionEnvironment.getExecutionEnvironment takes no parenthesis, appearing that way like a member of the class, rather than a method. Is there some rule when to use methods/functions with parenthesis, and when without? Greetings, Stephan |
Hi,
as far as I know, it is common to omit the parentheses if the method has no side effects. If it is not pure, then one adds the parentheses. Greets, Till On Mon, Oct 27, 2014 at 9:04 PM, Stephan Ewen <[hidden email]> wrote: > Hi! > > I have a question about the code conventions in Scala, or more > specifically, about methods without parenthesis. > > For example, the ExecutionEnvironment.getExecutionEnvironment takes no > parenthesis, appearing that way like a member of the class, rather than a > method. > > Is there some rule when to use methods/functions with parenthesis, and when > without? > > Greetings, > Stephan |
Yes, that is correct.
Scala has code style guide that is used and recommended in Scala based application. Here is the particular section about 0-arity method calls: http://docs.scala-lang.org/style/method-invocation.html - Henry On Mon, Oct 27, 2014 at 1:10 PM, Till Rohrmann <[hidden email]> wrote: > Hi, > > as far as I know, it is common to omit the parentheses if the method > has no side effects. If it is not pure, then one adds the parentheses. > > Greets, > > Till > > On Mon, Oct 27, 2014 at 9:04 PM, Stephan Ewen <[hidden email]> wrote: >> Hi! >> >> I have a question about the code conventions in Scala, or more >> specifically, about methods without parenthesis. >> >> For example, the ExecutionEnvironment.getExecutionEnvironment takes no >> parenthesis, appearing that way like a member of the class, rather than a >> method. >> >> Is there some rule when to use methods/functions with parenthesis, and when >> without? >> >> Greetings, >> Stephan |
Yes, I'm following that guide for my Scala code.
On Mon, Oct 27, 2014 at 11:04 PM, Henry Saputra <[hidden email]> wrote: > Yes, that is correct. > > Scala has code style guide that is used and recommended in Scala based > application. > Here is the particular section about 0-arity method calls: > http://docs.scala-lang.org/style/method-invocation.html > > - Henry > > On Mon, Oct 27, 2014 at 1:10 PM, Till Rohrmann <[hidden email]> wrote: >> Hi, >> >> as far as I know, it is common to omit the parentheses if the method >> has no side effects. If it is not pure, then one adds the parentheses. >> >> Greets, >> >> Till >> >> On Mon, Oct 27, 2014 at 9:04 PM, Stephan Ewen <[hidden email]> wrote: >>> Hi! >>> >>> I have a question about the code conventions in Scala, or more >>> specifically, about methods without parenthesis. >>> >>> For example, the ExecutionEnvironment.getExecutionEnvironment takes no >>> parenthesis, appearing that way like a member of the class, rather than a >>> method. >>> >>> Is there some rule when to use methods/functions with parenthesis, and when >>> without? >>> >>> Greetings, >>> Stephan |
Free forum by Nabble | Edit this page |