This is more about Scala than systems programming.
On slide http://monkey.org/~marius/talks/twittersystems/#16:
case class Stock(ticker: String, price: Double) {
def <(other: Stock) = price < other.price
}
val goog = Stock("GOOG", 675.15)
val aapl = Stock("AAPL", 604.00)
aapl < goog == true
goog < aapl == false
Correct me if I'm wrong but it seems to me that the class Stock gets a method called "<". So appl.< google (or the other way around) would also work. The previous slide also shows this, but the Stock example is makes it even clearer that "Scala is a pure object oriented language: every value is an object." appl and goog are objects, of type Stock, and < is an object, a method of Stock.I wonder if this kind of method would work
def ==(other: Stock) = price != other.price
and what would happen if it was like this def ==(other: Stock) = self != other
(where self would be a reference to the Stock instance, ala python, or this in javascript)and it was invoked like this
appl == goog
and return trueYou should download the Scala IDE and play with a feature called the "Worksheet".
See here: https://github.com/scala-ide/scala-worksheet/wiki/Getting-St...
Isn't this ability a bit dangerous or worrisome? It means that for every Scala package you use you need to review the code. It does make a good prank though :)
I wouldn't say it was particularly dangerous, but it is a massive pain to deal with (it also means you can google for any help with a particular method).