What is the difference between = and := in Scala?

后端 未结 4 1933
天涯浪人
天涯浪人 2020-12-24 00:41

What is the difference between = and := in Scala?

I have googled extensively for \"scala colon-equals\", but was unable to find anything de

4条回答
  •  萌比男神i
    2020-12-24 01:21

    Scala allows for operator overloading, where you can define the behaviour of an operator just like you could write a method.

    As in other languages, = is an assignment operator.

    The is no standard operator I'm aware of called :=, but could define one with this name. If you see an operator like this, you should check up the documentation of whatever you're looking at, or search for where that operator is defined.

    There is a lot you can do with Scala operators. You can essentially make an operator out of virtually any characters you like.

提交回复
热议问题