Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (19 sloc) 498 Bytes
package com.madhukaraphatak.scala.simple
object TraitExample {
trait Display {
def display()
}
class StringDisplay extends Display {
def display() = println("string display")
}
class IntDisplay extends Display {
def display() = println("int display")
}
def display(d :Display) = d.display()
def main(args: Array[String]) = {
val stringDisplay = new StringDisplay()
display(stringDisplay)
val intDisplay = new IntDisplay()
display(intDisplay)
}
}
You can’t perform that action at this time.