Link Details

Link 925099 thumbnail
User 1080911 avatar

By stoyanr
Submitted: Feb 17 2013 / 09:12

In this post, I use an example complex numbers class to illustrate important Scala concepts and features. I start with a very simple one-liner and gradually add more capabilities to it, while at the same time introducing the language features that make them possible. I end up with a more or less complete and usable complex numbers implementation in just a few lines of code, which nevertheless allows things that would not be possible with other languages (Java), such as operator arithmetics, seamless conversion between complex and real numbers, and "free" equality and comparison. If you are interested in Scala, but haven't mastered it yet, this can be a good introduction to the conciseness and power of this remarkable programming language.
  • 2
  • 0
  • 190
  • 75

Add your comment

Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Upvoters (2)

Downvoters (0)

    Apache Hadoop
    Written by: Piotr Krewski
    Featured Refcardz: Top Refcardz:
    1. Play
    2. Akka
    3. Design Patterns
    4. OO JS
    5. Cont. Delivery
    1. Play
    2. Java Performance
    3. Akka
    4. REST
    5. Java