Skip to content

Instantly share code, notes, and snippets.

@russ
Created August 19, 2010 15:36
Show Gist options
  • Save russ/538172 to your computer and use it in GitHub Desktop.
Save russ/538172 to your computer and use it in GitHub Desktop.
def greet(subject:String) {
def greeting(subject:String) = "Hello, %s!".format(subject)
println(greeting(subject))
}
greet("World")
class PlayerCharacter(name:String, hp:Int) {
def name() {
}
}
val ages = Map(
"Alice" -> 24,
"Bob" -> 27,
"Mallory" -> 16)
for ((name, age) <- ages) println(name + " - " + age)
object names {
def foreach[U](f:String => U) {
f("Alice")
f("Bob")
f("Mallory")
}
}
for (name <- names) println(name)
val src = """
Alice:25
Bob:25
Mallory:25
"""
val Re = """(\w+):(\d+)""".r
for (Re(name, age) <- (io.Source fromString src) getLines)
println(name + " - " + age)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment