Duck typing

Imagine that you want to proceed any instance or object that realizes a given contract i.e. that implements a given set of specific methods. The classical approach tells you to create a new abstraction (an Interface in Java, a Trait in Scala) that provides all the required method signatures. For instance:
/**
 * Using a trait
 */

trait Omnipotent {
  def doThis: String
  def doThat: String
}

def doEverything(o: Omnipotent) = {
  println(o.doThis)
  println(o.doThat)
}

object deity extends Omnipotent {
  def doThis: String = "This is done !!"
  def doThat: String = "That is done !!"
  def doTheRest: String = "Everything's done!!"
}

doEverything(deity)
Now, if you want to do the same thing without defining any additional trait, you can use a type definition instead:
/**
 * Using a type
 */

type Omnipotent = {
  def doThis: String
  def doThat: String
}

def doEverything(o : Omnipotent) = {
  println(o.doThis)
  println(o.doThat)
}

object deity {
  def doThis: String = "This is done !!"
  def doThat: String = "That is done !!"
  def doTheRest: String = "Everything's done!!"
}

doEverything(deity)
Compared to the previous example, the most important difference here is that the deity object doesn't extend anything, but is explicitly of type Omnipotent. Note that, if the newly created type is used only once, you can even declare it anonymously:
/**
 * Using an anonymous type
 */

def doEverything(o : {def doThis: String; def doThat: String}) = {
  println(o.doThis)
  println(o.doThat)
}

object deity {
  def doThis: String = "This is done !!"
  def doThat: String = "That is done !!"
  def doTheRest: String = "Everything's done!!"
}

doEverything(deity)

// another anonymous instance 
val dude = new {
  def doThis: String = "This, I can do !!"
  def doThat: String = "That, I can't .."
}

doEverything(dude)
This technique is called Duck Typing i.e. when "an object's current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class or implementation of a specific interface". This principle can be basically translated to "when I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck."

For additional (and clearer :)) information, please have a look to the following resources: