Wu Language
Search…
Getting Started
Writing code
Declarations
Optionals
If and While
For
Switch
Functions
Structs
Module
Traits
Powered By
GitBook
Switch
Switch expressions work basically like
if
and can be used like the following:
1
a
:=
compute_some_number
()
2
3
switch
a
{
4
|
0
=>
print
(
"a is zero"
)
5
|
10
=>
print
(
"a is ten"
)
6
|
_
=>
print
(
"something else"
)
7
}
Copied!
And can be used as expressions:
1
foo
:
str
=
switch
10
{
2
|
10
=>
"foo"
3
}
Copied!
Very nice.
Previous
For
Next
Functions
Last modified
2yr ago
Copy link