What's the difference between using and no using a “=” in Scala defs ?

后端 未结 5 696
情歌与酒
情歌与酒 2021-01-21 11:06

What the difference between the two defs below

def someFun(x:String) { x.length } 

AND

def someFun(x:String) = {          


        
5条回答
  •  一个人的身影
    2021-01-21 11:51

    As per Scala-2.10, using equals sign is preferred. Infact you must use equals sign in call declarations except the definitions returning Unit.

    As such there is no difference but the first one is not recommended anymore and it should not be used.

提交回复
热议问题