mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
update switch docs
This commit is contained in:
parent
7c4cd41fba
commit
05f6a0b7f7
@ -696,12 +696,15 @@ is done with the `==` operator.
|
|||||||
switch name
|
switch name
|
||||||
when "Robert"
|
when "Robert"
|
||||||
print "You are robert"
|
print "You are robert"
|
||||||
when "Dan"
|
when "Dan", "Daniel"
|
||||||
print "Your name, it's Dan"
|
print "Your name, it's Dan"
|
||||||
else
|
else
|
||||||
print "I don't know about your name"
|
print "I don't know about your name"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
A switch `when` clause can match against multiple values by listing them out
|
||||||
|
comma separated.
|
||||||
|
|
||||||
Switches can be used as expressions as well, here we can assign the result of
|
Switches can be used as expressions as well, here we can assign the result of
|
||||||
the switch to a variable:
|
the switch to a variable:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user