Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6791 > unrolled thread
| Started by | rantingrickjohnson@gmail.com |
|---|---|
| First post | 2013-04-30 22:15 -0700 |
| Last post | 2013-05-01 11:27 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.ruby
RubyWart: Missing Name Errors (AGAIN!) rantingrickjohnson@gmail.com - 2013-04-30 22:15 -0700
Re: RubyWart: Missing Name Errors (AGAIN!) Robert Klemme <shortcutter@googlemail.com> - 2013-05-01 11:27 +0200
| From | rantingrickjohnson@gmail.com |
|---|---|
| Date | 2013-04-30 22:15 -0700 |
| Subject | RubyWart: Missing Name Errors (AGAIN!) |
| Message-ID | <178bbf18-32c2-4ecb-8318-972617bfb332@googlegroups.com> |
Same bowel movement, different cess pool!
Can someone please explain the logic of having undefined symbols default to random values instead of throwing a NameError? Because this is making me F'ING NUTS PEOPLE!!!!
============================================================
Code Sample
============================================================
class Foo
def foo
$stdout.write("@poo = #{@poo}\n")
end
end
============================================================
Interactive Session
============================================================
rb> f = Foo.new
#<Foo:0x79e6680>
rb> f.foo
@poo = 7
============================================================
Resulting Emotional State
============================================================
ಠ_ಠ
[toc] | [next] | [standalone]
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Date | 2013-05-01 11:27 +0200 |
| Message-ID | <auc5glF4m42U1@mid.individual.net> |
| In reply to | #6791 |
On 05/01/2013 07:15 AM, rantingrickjohnson@gmail.com wrote:
> Same bowel movement, different cess pool!
>
> Can someone please explain the logic of having undefined symbols default to random values instead of throwing a NameError? Because this is making me F'ING NUTS PEOPLE!!!!
They don't. Also, this is not about an undefined Symbol but about an
unassigned member variable.
> ============================================================
> Code Sample
> ============================================================
> class Foo
> def foo
> $stdout.write("@poo = #{@poo}\n")
> end
> end
>
>
> ============================================================
> Interactive Session
> ============================================================
> rb> f = Foo.new
> #<Foo:0x79e6680>
> rb> f.foo
> @poo = 7
That output does not come from the code above:
irb(main):001:0> class Foo
irb(main):002:1> def foo
irb(main):003:2> $stdout.write("@poo = #{@poo}\n")
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> f = Foo.new
=> #<Foo:0x8f8bb84>
irb(main):007:0> f.foo
@poo =
=> 8
What you probably did:
irb(main):001:0> class Foo
irb(main):002:1> def foo
irb(main):003:2> $stdout.write("@poo = #{@poo}")
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> f = Foo.new
=> #<Foo:0x9285344>
irb(main):007:0> f.foo
@poo = => 7
Whatever interactive Ruby you used does not print "=> " in front of the
inspect of the last value. Now you also see why IRB does print this prefix.
> ============================================================
> Resulting Emotional State
> ============================================================
> ಠ_ಠ
It may actually be the other way round.
Kind regards
robert
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.ruby
csiph-web