Why to use empty parentheses in Scala if we can just use no parentheses to define a function which does not need any arguments? -
as far understand, in scala can define function no parameters either using empty parentheses after name, or no parentheses @ all, , these 2 definitions not synonyms. purpose of distinguishing these 2 syntaxes , when should better use 1 instead of another?
it's question of convention. methods empty parameter lists are, convention, evaluated side-effects. methods without parameters assumed side-effect free. that's convention.
Comments
Post a Comment