Created
July 26, 2010 06:08
-
-
Save dfreedm/490232 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
| Some: class <T> { | |
| content:T | |
| init:func <T> (=content){} | |
| get:func -> T {return content;} | |
| } | |
| // None is a builitin type | |
| main: func { | |
| a := Some<String> new("77777") | |
| b := None new() | |
| c := Some<Int> new(8) | |
| printMaybe(a) | |
| printMaybe(b) | |
| printMaybe(c) | |
| } | |
| printMaybe: func ~SomeString (a:Some<String>) { | |
| "I'm printin' a string" println() | |
| a get() println() | |
| } | |
| printMaybe: func ~SomeInt (a:Some<Int>){ | |
| "I'm printin' an int" println() | |
| a get() toString() println() | |
| } | |
| printMaybe: func ~None (a:None) { | |
| "This is a none" println() | |
| } | |
| /* | |
| What Should Happen | |
| ------------------ | |
| I'm printin' a string | |
| 77777 | |
| This is a none | |
| I'm printin' an int | |
| 8 | |
| What Actually Happens | |
| --------------------- | |
| I'm printin' a string | |
| 77777 | |
| This is a none | |
| I'm printin' a string | |
| zsh: segmentation fault ./maybe | |
| */ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What Should Happen
I'm printin' a string 77777 This is a none I'm printin' an int 8What Actually Happens
I'm printin' a string 77777 This is a none I'm printin' a string zsh: segmentation fault ./maybe