Scala - infix vs dot notation

前端 未结 4 851
忘了有多久
忘了有多久 2020-12-07 23:00

Is there a best practice for one over the other? I\'ve been reading the Scala book by Odersky, et al. and it seems like infix is used for a lot of the Collections

4条回答
  •  借酒劲吻你
    2020-12-07 23:10

    It's a matter of personal preference. Your decision to use one style or the other should be based on what makes your code the most readable.

    But note that the ability to leave off the dot and parentheses is limited only to certain syntactic constructions, so sometimes you just have to fall back to using them.

提交回复
热议问题