def quacker(duck: {def quack(value: String): String}) {
println (duck.quack("Quack"))
}
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:
The above quacker method accepts any “duck” that can quack.
Read the full article here:
http://java.dzone.com/articles/duck-typing-scala-structural
