Skip to content

doc(de): improve documentation #3463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions de/documentation/quickstart/2/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ Was machen wir, wenn wir ganz oft “Hallo” sagen wollen, ohne uns die
Finger wund zu tippen? Wir definieren eine Methode!

{% highlight irb %}
irb(main):010:0> def h
irb(main):010:0> def hi
irb(main):011:1> puts "Hallo, Welt!"
irb(main):012:1> end
=> nil
=> :hi
{% endhighlight %}

Mit dem Code `def h` beginnt man die Methodendefinition. Er teilt Ruby
mit, dass wir eine Methode definieren, deren Name `h` ist. Die nächste
Mit dem Code `def hi` beginnt man die Methodendefinition. Er teilt Ruby
mit, dass wir eine Methode definieren, deren Name `hi` ist. Die nächste
Zeile nennt man Rumpf (“Body”) der Methode. Sie ist identisch zu der
Zeile, die wir schon von vorhin kennen: `puts "Hallo, Welt!"`. Und
schließlich teilt die letzte Zeile `end` Ruby mit, dass wir fertig mit
der Methodendefinition sind. Rubys Antwort `=> nil` sagt uns, dass Ruby
der Methodendefinition sind. Rubys Antwort `=> :hi` sagt uns, dass Ruby
das nun weiß.

## Die kurzen, immer wiederkehrenden Lebenszyklen einer Methode

Rufen wir nun die Methode ein paar Mal auf:

{% highlight irb %}
irb(main):013:0> h
irb(main):013:0> hi
Hallo, Welt!
=> nil
irb(main):014:0> h()
irb(main):014:0> hi()
Hallo, Welt!
=> nil
{% endhighlight %}
Expand All @@ -55,15 +55,15 @@ Klammer-Paar ans Ende des Methodennamens setzen, aber das ist nicht
notwendig.

Was, wenn wir nun Hallo zu einer ganz bestimmten Person statt zur ganzen
Welt sagen möchten? Dann definieren wir `h` einfach neu, so dass ein
Welt sagen möchten? Dann definieren wir `hi` einfach neu, so dass ein
Name als Parameter akzeptiert wird:

{% highlight irb %}
irb(main):015:0> def h(name)
irb(main):015:0> def hi(name)
irb(main):016:1> puts "Hallo, #{name}!"
irb(main):017:1> end
=> nil
irb(main):018:0> h("Matz")
=> :hi
irb(main):018:0> hi("Matz")
Hallo, Matz!
=> nil
{% endhighlight %}
Expand All @@ -81,14 +81,14 @@ man auch dazu benutzen, um sicherzugehen, dass der Name einer Person mit
einem Großbuchstaben anfängt:

{% highlight irb %}
irb(main):019:0> def h(name = "Welt")
irb(main):019:0> def hi(name = "Welt")
irb(main):020:1> puts "Hallo, #{name.capitalize}!"
irb(main):021:1> end
=> nil
irb(main):022:0> h "chris"
=> :hi
irb(main):022:0> hi "chris"
Hallo, Chris!
=> nil
irb(main):023:0> h
irb(main):023:0> hi
Hallo, Welt!
=> nil
{% endhighlight %}
Expand Down Expand Up @@ -119,7 +119,7 @@ irb(main):031:1> def sag_tschuess
irb(main):032:2> puts "Tschuess, #{@name}, bis bald!"
irb(main):033:2> end
irb(main):034:1> end
=> nil
=> :sag_tschuess
{% endhighlight %}

Das neue Schlüsselwort hier ist `class`. Damit definieren wir eine neue
Expand Down
29 changes: 16 additions & 13 deletions de/documentation/quickstart/3/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ Hmm, und wenn wir direkt auf den Namen im Objekt zugreifen wollen?

{% highlight irb %}
irb(main):038:0> g.@name
SyntaxError: compile error
(irb):52: syntax error
from (irb):52
<internal:kernel>:187:in `loop': (irb):52: syntax error, unexpected instance variable (SyntaxError)
{% endhighlight %}

Nö, das geht offensichtlich nicht.
Expand All @@ -53,16 +51,21 @@ Welche Methoden existieren nun für Greeter-Objekte?

{% highlight irb %}
irb(main):039:0> Greeter.instance_methods
=> ["method", "send", "object_id", "singleton_methods",
"__send__", "equal?", "taint", "frozen?",
"instance_variable_get", "kind_of?", "to_a",
"instance_eval", "type", "protected_methods", "extend",
"eql?", "display", "instance_variable_set", "hash",
"is_a?", "to_s", "class", "tainted?", "private_methods",
"untaint", "sag_hallo", "id", "inspect", "==", "===",
"clone", "public_methods", "respond_to?", "freeze",
"sag_tschuess", "__id__", "=~", "methods", "nil?", "dup",
"instance_variables", "instance_of?"]
=>
[:sag_hallo, :sag_tschuess, :to_yaml, :to_json,
:pretty_print, :pretty_print_inspect, :pretty_print_cycle,
:pretty_print_instance_variables, :Namespace,
:singleton_class, :dup, :itself, :methods,
:singleton_methods, :protected_methods, :private_methods,
:public_methods, :instance_variables, :instance_variable_get,
:instance_variable_set, :instance_variable_defined?,
:remove_instance_variable, :instance_of?, :kind_of?, :is_a?,
:display, :TypeName, :public_send, :extend, :clone, :<=>,
:===, :class, :!~, :tap, :frozen?, :yield_self, :then, :nil?,
:eql?, :respond_to?, :method, :public_method, :singleton_method,
:define_singleton_method, :hash, :freeze, :inspect, :object_id,
:send, :to_s, :pretty_inspect, :to_enum, :enum_for, :equal?, :!,
:__send__, :==, :!=, :instance_eval, :instance_exec, :__id__]
{% endhighlight %}

Hoppla, das sind aber ganz schön viele! Wir haben doch nur zwei Methoden
Expand Down
Loading