I’ve recently learned that irb and ruby (ruby interpreter) behave
and that irb is not running on ruby interpreter.
As an example,
[[email protected] src]$ irb
irb(main):001:0> def foo
irb(main):002:1> puts “foo”
irb(main):004:0> class Bar; end
irb let me call foo which is non-sense.
[[email protected] src]$ cat > test.rb
class Bar; end
[[email protected] src]$ ruby test.rb
test.rb:5: private method `foo’ called for #Bar:0x2aaaaab00cc8
[[email protected] src]$
Ruby interpreter fails as expected.
So, here’s my question. Why is irb running on its own interpreter(or
simulator or whatever)?