Created
November 21, 2013 20:16
-
-
Save dvliman/7588845 to your computer and use it in GitHub Desktop.
we can put object inside a trait in Scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Dog { | |
def bark { | |
println("barking") | |
} | |
} | |
trait Animal { | |
object Cat { | |
def meow { | |
println("meowing") | |
} | |
} | |
} | |
object AnimalLike extends Animal {} | |
object Main { | |
def main(args: Array[String]) { | |
Dog.bark | |
AnimalLike.Cat.meow | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment