Created
May 10, 2012 21:57
-
-
Save fedesilva/2656161 to your computer and use it in GitHub Desktop.
Voldemort types 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
f@omoikane:~$ scala | |
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> :load Workshop/mine/scala-misc/voldemort.scala | |
Loading Workshop/mine/scala-misc/voldemort.scala... | |
defined module Dungeon | |
scala> val nemesis = Dungeon curse "fedesilva" | |
nemesis: java.lang.Object with ScalaObject{def shout: Unit} = I came back to haunt fedesilva | |
scala> nemesis.shout | |
fedesilvaaaaaaaaaaa!!!!! |
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
/* You will pardon my Potteresque ignorance but where does Voldemort live? is a dungeon acceptable? */ | |
object Dungeon { | |
def curse(reason:String) = { | |
class Voldemort(revenge:String) { | |
def shout { println(revenge+revenge.last.toString*10+"!"*5) } | |
override def toString() = "I came back to haunt "+revenge | |
} | |
new Voldemort(reason) // last expression returns | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@fedesilva Voldemorts live in Chambers. Specifically the Chamber of Secrets