Monthly Archive for December, 2010

Page 2 of 2

Unicode Traits in Scala

Imagine for a moment, the following:

trait UnicodeOrdered {
    def < (that: Any): Boolean = (this < that)
    def ≤ (that: Any): Boolean = (this < that) || (this == that)
    def > (that: Any): Boolean = !(this ≤ that)
    def ≥ (that: Any): Boolean = (this > that) || (this == that)
  }

This is a cool feature, useful in the implementation of DSL’s, in Scala.