Struggle against habits formed by Java when migrating to Scala

后端 未结 7 686
星月不相逢
星月不相逢 2021-02-01 08:48

What are the most common mistakes that Java developers make when migrating to Scala?

By mistakes I mean writing a code that does not conform to Scala spirit, for example

相关标签:
7条回答
  • 2021-02-01 09:40

    A common mistake is to go wild and overuse a feature not present in Java once you "grokked" it. E.g. newbies tend to overuse pattern matching(*), explicit recursion, implicit conversions, (pseudo-) operator overloading and so on. Another mistake is to misuse features that look superficially similar in Java (but ain't), like for-comprehensions or even if (which works more like Java's ternary operator ?:).

    (*) There is a great cheat sheet for pattern matching on Option: http://blog.tmorris.net/scalaoption-cheat-sheet/

    0 讨论(0)
提交回复
热议问题