Skip to content

Instantly share code, notes, and snippets.

@netologist
Created August 7, 2014 07:03
Show Gist options
  • Save netologist/11324e0ea91d59e71fd2 to your computer and use it in GitHub Desktop.
Save netologist/11324e0ea91d59e71fd2 to your computer and use it in GitHub Desktop.
Scala Prompt Sample
// Works Scala 2.11
import scala.io.StdIn._
object Main extends App {
var items:List[String] = List.empty
var ok = true
while(ok) {
print("> ")
val line = readLine
val item = line.split(" ")
item(0) match {
case "exit" => ok = false
case "add" => items = (item(1) :: items)
case "list" => items.map(println)
case _ => println("unknown command")
}
println
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment