Created
November 18, 2010 07:36
-
-
Save ymnk/704727 to your computer and use it in GitHub Desktop.
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 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") |
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 org.java{ | |
} | |
package org.myproject{ | |
class Bar extends java.net.Socket | |
} |
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 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._ } |
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 gardening | |
package object fruits { | |
val planted = List(apple, plum, banana) | |
def showFruit(fruit: Fruit) { | |
println(fruit.name +"s are "+ fruit.color) | |
} | |
} |
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
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