@@ -35,9 +35,7 @@ Hmm, und wenn wir direkt auf den Namen im Objekt zugreifen wollen?
35
35
36
36
{% highlight irb %}
37
37
irb(main):038:0> g.@name
38
- SyntaxError: compile error
39
- (irb):52: syntax error
40
- from (irb):52
38
+ < internal:kernel > :187: in `loop': (irb):52: syntax error, unexpected instance variable (SyntaxError)
41
39
{% endhighlight %}
42
40
43
41
Nö, das geht offensichtlich nicht.
@@ -53,16 +51,21 @@ Welche Methoden existieren nun für Greeter-Objekte?
53
51
54
52
{% highlight irb %}
55
53
irb(main):039:0> Greeter.instance_methods
56
- => [ "method", "send", "object_id", "singleton_methods",
57
- "__ send__ ", "equal?", "taint", "frozen?",
58
- "instance_variable_get", "kind_of?", "to_a",
59
- "instance_eval", "type", "protected_methods", "extend",
60
- "eql?", "display", "instance_variable_set", "hash",
61
- "is_a?", "to_s", "class", "tainted?", "private_methods",
62
- "untaint", "sag_hallo", "id", "inspect", "==", "===",
63
- "clone", "public_methods", "respond_to?", "freeze",
64
- "sag_tschuess", "__ id__ ", "=~ ", "methods", "nil?", "dup",
65
- "instance_variables", "instance_of?"]
54
+ =>
55
+ [ : sag_hallo , : sag_tschuess , : to_yaml , : to_json ,
56
+ : pretty_print , : pretty_print_inspect , : pretty_print_cycle ,
57
+ : pretty_print_instance_variables , : Namespace ,
58
+ : singleton_class , : dup , : itself , : methods ,
59
+ : singleton_methods , : protected_methods , : private_methods ,
60
+ : public_methods , : instance_variables , : instance_variable_get ,
61
+ : instance_variable_set , : instance_variable_defined ?,
62
+ : remove_instance_variable , : instance_of ?, : kind_of ?, : is_a ?,
63
+ : display , : TypeName , : public_send , : extend , : clone , :<=>,
64
+ :===, : class , :!~ , : tap , : frozen ?, : yield_self , : then , : nil ?,
65
+ : eql ?, : respond_to ?, : method , : public_method , : singleton_method ,
66
+ : define_singleton_method , : hash , : freeze , : inspect , : object_id ,
67
+ : send , : to_s , : pretty_inspect , : to_enum , : enum_for , : equal ?, :!,
68
+ :__ send__ , :==, :!=, : instance_eval , : instance_exec , :__ id__ ]
66
69
{% endhighlight %}
67
70
68
71
Hoppla, das sind aber ganz schön viele! Wir haben doch nur zwei Methoden
0 commit comments