Skip to content

Commit b833282

Browse files
committed
fixed some broken syntax in docs
1 parent 4b56fb2 commit b833282

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/reference.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -424,23 +424,23 @@ Here we can set the minimum and maximum bounds, taking all items with indexes
424424
between 1 and 5 inclusive:
425425

426426
```moon
427-
slice = [item for item in *items[1:5]]
427+
slice = [item for item in *items[1,5]]
428428
```
429429

430430
Any of the slice arguments can be left off to use a sensible default. In this
431431
example, if the max index is left off it defaults to the length of the table.
432432
This will take everything but the first element:
433433

434434
```moon
435-
slice = [item for item in *items[2:]]
435+
slice = [item for item in *items[2,]]
436436
```
437437

438438
If the minimum bound is left out, it defaults to 1. Here we only provide a step
439439
size and leave the other bounds blank. This takes all odd indexed items: (1, 3,
440440
5, ...)
441441

442442
```moon
443-
slice = [item for items in *items[::2]]
443+
slice = [item for items in *items[,,2]]
444444
```
445445

446446
## For Loop
@@ -461,7 +461,7 @@ There are two for loop forms, just like in Lua. A numeric one and a generic one:
461461
The slicing and `*` operators can be used, just like with table comprehensions:
462462

463463
```moon
464-
for item in *items[2:4]
464+
for item in *items[2,4]
465465
print item
466466
```
467467

@@ -595,9 +595,9 @@ is done with the `==` operator.
595595
```moon
596596
name = "Dan"
597597
switch name
598-
case "Robert"
598+
when "Robert"
599599
print "You are robert"
600-
case "Dan"
600+
when "Dan"
601601
print "Your name, it's Dan"
602602
else
603603
print "I don't know about your name"
@@ -609,21 +609,21 @@ the switch to a variable:
609609
```moon
610610
b = 1
611611
next_number = switch b
612-
case 1
612+
when 1
613613
2
614-
case 2
614+
when 2
615615
3
616616
else
617617
error "can't count that high!"
618618
```
619619

620-
We can use the `then` keyword to write a switch case's block on a single line.
620+
We can use the `then` keyword to write a switch's `when` block on a single line.
621621
No extra keyword is needed to write the else block on a single line.
622622

623623
```moon
624624
msg = switch math.random(1, 5)
625-
case 1 then "you are lucky"
626-
case 2 then "you are almost lucky"
625+
when 1 then "you are lucky"
626+
when 2 then "you are almost lucky"
627627
else "not so lucky"
628628
```
629629

0 commit comments

Comments
 (0)