Created
January 26, 2012 02:41
-
-
Save jjhop/1680621 to your computer and use it in GitHub Desktop.
scala.actors zabaway ze ScalaIDE
This file contains 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
package info.jjhop.mp | |
import scala.actors._ | |
case class Name(val name:String) { | |
override def toString():String = name | |
} | |
class GreetingsActor extends Actor { | |
def act = { | |
loop { | |
receive { | |
case Name(n) => println("Dostalem: " + n.toString) | |
case "quit" => { | |
println("robimy wypad") | |
exit() | |
} | |
case _ => println("???") | |
} | |
} | |
} | |
} | |
object MyProgram { | |
def main(args: Array[String]): Unit = { | |
println("Hello world!") | |
var vals = List(Name("Rafal"), Name("Kamilka"), Name("Zosia"), "Hello", 1L) // | |
val a = new GreetingsActor | |
a.start | |
vals.foreach { i => a ! i} | |
a ! "quit" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment