|
1 | 1 | --- |
2 | | -lang: EN |
3 | | -title: To (be) or not to (be) |
| 2 | +lang: DE |
| 3 | +title: "To (be) or not to (be)" |
4 | 4 | answer: |
5 | | -load: poem = "My toast has flown from my hand\nAnd my toast has gone to the moon.\nYada yada yada\n" |
| 5 | +load: poem = "Mein Toast ist mir aus der Hand geflogen\nUnd mein Toast ist zum Mond geflogen.\nBlablabla\n" |
6 | 6 | ok: |
7 | 7 | error: |
8 | 8 | --- |
9 | 9 |
|
10 | | -One other little thing we haven't really talked about openly: method arguments. |
11 | | -Remember when we changed the poem a little bit? We used: |
12 | | -__poem.gsub("toast", "honeydew")__ |
| 10 | +Eine weitere kleine Sache, über die wir noch nicht wirklich offen gesprochen |
| 11 | +haben: Argumente von Methoden. |
| 12 | +Weißt du noch, wie wir das Gedicht ein wenig verändert haben? Wir verwendeten: |
| 13 | +poem.gsub("Toast", "Melonenstück") |
13 | 14 |
|
14 | | -The gsub method needs 2 arguments, which we passed to gsub by including two strings between |
15 | | -parentheses. _Arguments tell the method exactly what to do._ |
| 15 | +Die Methode gsub benötigt 2 Argumente, die wir an gsub übergeben, indem wir |
| 16 | +zwei Strings zwischen Klammern einfügen. _Argumente sagen der Methode genau, |
| 17 | +was sie tun soll._ |
16 | 18 |
|
17 | | -### Parentheses |
18 | | -Actually, most of the time Ruby doesn't mind if you omit the parentheses. So this would have |
19 | | -worked too: |
20 | | -__poem.gsub "toast", "honeydew"__ |
| 19 | +### Klammern |
| 20 | +Eigentlich macht es Ruby meistens nichts aus, wenn man die Klammern weglässt. |
| 21 | +Das hätte also auch funktioniert: |
| 22 | +__poem.gsub "Toast", "Melonenstück"__ |
21 | 23 |
|
22 | | -We have already used another method with a parameter. Many times in fact, though it was not very |
23 | | -obvious: |
| 24 | +Wir haben bereits eine andere Methode mit einem Parameter verwendet. Und zwar |
| 25 | +schon oft, obwohl es nicht sehr offensichtlich war: |
24 | 26 |
|
25 | | - puts "Hello" |
26 | | - puts("Hello") |
| 27 | + puts "Hallo" |
| 28 | + puts("Hallo") |
27 | 29 |
|
28 | | -Yes __puts__ is also a method. Using puts with or without parentheses is the same to Ruby, but the |
29 | | -version without parentheses is a bit easier to read. And it saves you valuable typing time! |
| 30 | +Ja, __puts__ ist auch eine Methode. Die Verwendung von puts mit oder ohne |
| 31 | +Klammern ist für Ruby dasselbe, aber die Version ohne Klammern ist etwas |
| 32 | +einfacher zu lesen. Und sie spart wertvolle Zeit beim Tippen! |
30 | 33 |
|
31 | | -> So I guess the conclusion is that you can do whatever you like with parentheses as long as your |
32 | | -> code reads nicely. |
| 34 | +> Die Schlussfolgerung ist wohl, dass du mit Klammern machen kannst, was du |
| 35 | +willst, solange dein Code gut lesbar ist. |
33 | 36 |
|
34 | 37 | ### to (be) or not to (be) |
35 | | -So if _to_ is a method and _be_ is an argument we now know the answer to this age old question. |
36 | | -It is really just a matter of preference whether you want _to be_ or _to(be)_. |
| 38 | +Wenn also _to_ eine Methode und _be_ ein Argument ist, kennen wir jetzt die |
| 39 | +Antwort auf diese uralte Frage. |
| 40 | +Es ist wirklich nur eine Frage der Vorliebe, ob du _ to be_ oder _to (be)_ |
| 41 | +sein willst. |
37 | 42 |
|
38 | | -Are you in the mood for more Shakespeare? Read on. |
| 43 | +Hast du Lust auf mehr Shakespeare? Lies weiter. |
0 commit comments