diff options
Diffstat (limited to 'doc/docs/de')
| -rw-r--r-- | doc/docs/de/doc/control-flow/conditionals.md | 58 | ||||
| -rw-r--r-- | doc/docs/de/doc/control-flow/goto.md | 106 |
2 files changed, 164 insertions, 0 deletions
diff --git a/doc/docs/de/doc/control-flow/conditionals.md b/doc/docs/de/doc/control-flow/conditionals.md index 56663d1..0d2574d 100644 --- a/doc/docs/de/doc/control-flow/conditionals.md +++ b/doc/docs/de/doc/control-flow/conditionals.md | |||
| @@ -143,3 +143,61 @@ if a in list | |||
| 143 | ``` | 143 | ``` |
| 144 | 144 | ||
| 145 | </YueDisplay> | 145 | </YueDisplay> |
| 146 | |||
| 147 | Der `in`-Operator kann auch mit Tabellen verwendet werden und unterstützt die Variante `not in` für Verneinungen: | ||
| 148 | |||
| 149 | ```yuescript | ||
| 150 | has = "foo" in {"bar", "foo"} | ||
| 151 | |||
| 152 | if a in {1, 2, 3} | ||
| 153 | print "a ist in der Tabelle" | ||
| 154 | |||
| 155 | not_exist = item not in list | ||
| 156 | |||
| 157 | check = -> value not in table | ||
| 158 | ``` | ||
| 159 | |||
| 160 | <YueDisplay> | ||
| 161 | |||
| 162 | ```yue | ||
| 163 | has = "foo" in {"bar", "foo"} | ||
| 164 | |||
| 165 | if a in {1, 2, 3} | ||
| 166 | print "a ist in der Tabelle" | ||
| 167 | |||
| 168 | not_exist = item not in list | ||
| 169 | |||
| 170 | check = -> value not in table | ||
| 171 | ``` | ||
| 172 | |||
| 173 | </YueDisplay> | ||
| 174 | |||
| 175 | Eine Ein-Element-Liste oder Tabelle prüft auf Gleichheit mit diesem Element: | ||
| 176 | |||
| 177 | ```yuescript | ||
| 178 | -- [1,] prüft, ob wert == 1 | ||
| 179 | c = a in [1,] | ||
| 180 | |||
| 181 | -- {1} prüft auch, ob wert == 1 | ||
| 182 | c = a in {1} | ||
| 183 | |||
| 184 | -- Ohne Komma ist [1] ein Indexzugriff (tb[1]) | ||
| 185 | with tb | ||
| 186 | c = a in [1] | ||
| 187 | ``` | ||
| 188 | |||
| 189 | <YueDisplay> | ||
| 190 | |||
| 191 | ```yue | ||
| 192 | -- [1,] prüft, ob wert == 1 | ||
| 193 | c = a in [1,] | ||
| 194 | |||
| 195 | -- {1} prüft auch, ob wert == 1 | ||
| 196 | c = a in {1} | ||
| 197 | |||
| 198 | -- Ohne Komma ist [1] ein Indexzugriff (tb[1]) | ||
| 199 | with tb | ||
| 200 | c = a in [1] | ||
| 201 | ``` | ||
| 202 | |||
| 203 | </YueDisplay> | ||
diff --git a/doc/docs/de/doc/control-flow/goto.md b/doc/docs/de/doc/control-flow/goto.md new file mode 100644 index 0000000..0e2a415 --- /dev/null +++ b/doc/docs/de/doc/control-flow/goto.md | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | # Goto | ||
| 2 | |||
| 3 | YueScript unterstützt die goto-Anweisung und die Label-Syntax zur Steuerung des Programmflusses, wobei die gleichen Regeln wie bei Luas goto-Anweisung gelten. **Hinweis:** Die goto-Anweisung erfordert Lua 5.2 oder höher. Beim Kompilieren zu Lua 5.1 führt die Verwendung der goto-Syntax zu einem Kompilierfehler. | ||
| 4 | |||
| 5 | Ein Label wird mit doppelten Doppelpunkten definiert: | ||
| 6 | |||
| 7 | ```yuescript | ||
| 8 | ::start:: | ||
| 9 | ::done:: | ||
| 10 | ::mein_label:: | ||
| 11 | ``` | ||
| 12 | |||
| 13 | <YueDisplay> | ||
| 14 | |||
| 15 | ```yue | ||
| 16 | ::start:: | ||
| 17 | ::done:: | ||
| 18 | ::mein_label:: | ||
| 19 | ``` | ||
| 20 | |||
| 21 | </YueDisplay> | ||
| 22 | |||
| 23 | Die goto-Anweisung springt zu einem angegebenen Label: | ||
| 24 | |||
| 25 | ```yuescript | ||
| 26 | a = 0 | ||
| 27 | ::start:: | ||
| 28 | a += 1 | ||
| 29 | goto done if a == 5 | ||
| 30 | goto start | ||
| 31 | ::done:: | ||
| 32 | print "a ist jetzt 5" | ||
| 33 | ``` | ||
| 34 | |||
| 35 | <YueDisplay> | ||
| 36 | |||
| 37 | ```yue | ||
| 38 | a = 0 | ||
| 39 | ::start:: | ||
| 40 | a += 1 | ||
| 41 | goto done if a == 5 | ||
| 42 | goto start | ||
| 43 | ::done:: | ||
| 44 | print "a ist jetzt 5" | ||
| 45 | ``` | ||
| 46 | |||
| 47 | </YueDisplay> | ||
| 48 | |||
| 49 | Die goto-Anweisung ist nützlich, um aus tief verschachtelten Schleifen zu springen: | ||
| 50 | |||
| 51 | ```yuescript | ||
| 52 | for z = 1, 10 | ||
| 53 | for y = 1, 10 do for x = 1, 10 | ||
| 54 | if x^2 + y^2 == z^2 | ||
| 55 | print 'Pythagoreisches Tripel gefunden:', x, y, z | ||
| 56 | goto ok | ||
| 57 | ::ok:: | ||
| 58 | ``` | ||
| 59 | |||
| 60 | <YueDisplay> | ||
| 61 | |||
| 62 | ```yue | ||
| 63 | for z = 1, 10 | ||
| 64 | for y = 1, 10 do for x = 1, 10 | ||
| 65 | if x^2 + y^2 == z^2 | ||
| 66 | print 'Pythagoreisches Tripel gefunden:', x, y, z | ||
| 67 | goto ok | ||
| 68 | ::ok:: | ||
| 69 | ``` | ||
| 70 | |||
| 71 | </YueDisplay> | ||
| 72 | |||
| 73 | Sie können auch Labels verwenden, um zu einer bestimmten Schleifenebene zu springen: | ||
| 74 | |||
| 75 | ```yuescript | ||
| 76 | for z = 1, 10 | ||
| 77 | for y = 1, 10 | ||
| 78 | for x = 1, 10 | ||
| 79 | if x^2 + y^2 == z^2 | ||
| 80 | print 'Pythagoreisches Tripel gefunden:', x, y, z | ||
| 81 | print 'versuche nächstes z...' | ||
| 82 | goto zcontinue | ||
| 83 | ::zcontinue:: | ||
| 84 | ``` | ||
| 85 | |||
| 86 | <YueDisplay> | ||
| 87 | |||
| 88 | ```yue | ||
| 89 | for z = 1, 10 | ||
| 90 | for y = 1, 10 | ||
| 91 | for x = 1, 10 | ||
| 92 | if x^2 + y^2 == z^2 | ||
| 93 | print 'Pythagoreisches Tripel gefunden:', x, y, z | ||
| 94 | print 'versuche nächstes z...' | ||
| 95 | goto zcontinue | ||
| 96 | ::zcontinue:: | ||
| 97 | ``` | ||
| 98 | |||
| 99 | </YueDisplay> | ||
| 100 | |||
| 101 | ## Hinweise | ||
| 102 | |||
| 103 | - Labels müssen innerhalb ihres Geltungsbereichs eindeutig sein | ||
| 104 | - goto kann zu Labels auf derselben oder äußeren Geltungsbereichsebenen springen | ||
| 105 | - goto kann nicht in innere Geltungsbereiche springen (wie in Blöcke oder Schleifen) | ||
| 106 | - Verwenden Sie goto sparsam, da es den Code schwieriger zu lesen und zu warten machen kann | ||
