Update Jump Keyword
@@ -9,3 +9,18 @@ Time Complexity:
|
||||
The `jump` keyword allows you to modify the order in which commands are executed by jumping directly to a certain line of the program.
|
||||
|
||||
## Example usage
|
||||
```grnd
|
||||
jump %end # jump to @end
|
||||
println "Hello!" # this appends 'Hello\n' to stdout
|
||||
@end
|
||||
```
|
||||
This program immediately jumps to @end, completely skipping the `println "Hello!"` statement. As a result, this program does nothing to stdout.
|
||||
|
||||
We can also jump backwards and make an infinite loop.
|
||||
|
||||
```grnd
|
||||
@loop
|
||||
# ...
|
||||
jump %loop
|
||||
```
|
||||
This program will run the code inserted at `# ...`, then jump back to the start of the loop. This makes the code inserted at `# ...` be repeated forever.
|
||||
Reference in New Issue
Block a user