Created
August 15, 2010 15:18
-
-
Save fredreichbier/525596 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 structs/[ArrayList,HashMap] | |
| A: class { | |
| hello: String | |
| init: func (=hello) {} | |
| } | |
| B: class extends A { | |
| init: super func | |
| } | |
| globalA := A new("THE WHOLE WORLD") | |
| test: func (value: Object) { | |
| match(value) { | |
| case globalA => { | |
| "Global A! %s" format(value as A hello) println() | |
| } | |
| case b: B => { | |
| "B! %s" format(b hello) println() | |
| } | |
| case a: A => { | |
| "A! %s" format(a hello) println() | |
| } | |
| } | |
| } | |
| testGeneric: func <T> (value: T) { | |
| match(value) { | |
| case a: Int => { | |
| "Int! %d" format(a) println() | |
| } | |
| case s: String => "String! %s" format(s) println() | |
| case => { | |
| "No idea" println() | |
| } | |
| } | |
| } | |
| main: func { | |
| test(A new("World!")) | |
| test(B new("Borld!")) | |
| test(globalA) | |
| testGeneric(123) | |
| testGeneric("huhu") | |
| testGeneric(false) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! It could be used in many places in rock