Duck Typing in Scala: Structural Typing

Scala goes very far with its loads of features improving the JVM world. Sometimes, a bit too far, maybe. But this feature here is just plain awesome! Typesafe duck typing! An example:

def quacker(duck: {def quack(value: String): String}) {
  println (duck.quack("Quack"))

The above quacker method accepts any “duck” that can quack.

Read the full article here: