Skip to content

Instantly share code, notes, and snippets.

@ymnk
Created November 18, 2010 07:36
Show Gist options
  • Save ymnk/704727 to your computer and use it in GitHub Desktop.
Save ymnk/704727 to your computer and use it in GitHub Desktop.
package gardening.fruits
case class Fruit(name: String, color: String)
object apple extends Fruit("Apple", "green")
object plum extends Fruit("Plum", "blue")
object banana extends Fruit("Banana", "yellow")
package org.java{
}
package org.myproject{
class Bar extends java.net.Socket
}
package org.myproject.web {
}
package org.myproject {
package tests {
import web._
}
}
// The following definition will cause a compilation error on Scala 2.8
// package org.myproject.tests { import web._ }
package gardening
package object fruits {
val planted = List(apple, plum, banana)
def showFruit(fruit: Fruit) {
println(fruit.name +"s are "+ fruit.color)
}
}
import gardening.fruits._
object PrintPlanted {
def main(args: Array[String]) {
for (fruit: Fruit <- planted) {
showFruit(fruit)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment