What is the formal difference in Scala between braces and parentheses, and when should they be used?

后端 未结 9 1112
萌比男神i
萌比男神i 2020-11-22 07:09

What is the formal difference between passing arguments to functions in parentheses () and in braces {}?

The feeling I got from the Pro

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 08:01

    With braces, you got semicolon induced for you and parentheses not. Consider takeWhile function, since it expects partial function, only {case xxx => ??? } is valid definition instead of parentheses around case expression.

提交回复
热议问题