Created
March 14, 2020 06:55
-
-
Save xmeta/025bfd6d97a9599823bcf7da05335b39 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
enum Color { | |
red | |
blue | |
green | |
} | |
struct Rgb{ | |
r int | |
g int | |
b int | |
} | |
type MColor = Color | Rgb | |
fn is_red_or_blue(c MColor) bool { | |
return match c { | |
Color { | |
match it { | |
.red {true} | |
.blue {false} | |
else {false} | |
} | |
} | |
Rgb { true } | |
else {false} | |
} | |
} | |
fn main() { | |
print(is_red_or_blue(Color.red)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment