Skip to content

Instantly share code, notes, and snippets.

@dfreedm
Created July 26, 2010 06:08
Show Gist options
  • Select an option

  • Save dfreedm/490232 to your computer and use it in GitHub Desktop.

Select an option

Save dfreedm/490232 to your computer and use it in GitHub Desktop.
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
*/
@dfreedm
Copy link
Author

dfreedm commented Jul 26, 2010

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment