ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Differences between irb and ruby.
by Minkoo Seo other posts by this author
Jun 30 2006 7:11PM messages near this date
Re: Java to Ruby | Re: Differences between irb and ruby.
Hi list.

I've recently learned that irb and ruby (ruby interpreter) behave
differently often
and that irb is not running on ruby interpreter.

As an example,

[mkseo@uranus src]$ irb
irb(main):001:0>  def foo
irb(main):002:1>    puts "foo"
irb(main):003:1>  end
=>  nil
irb(main):004:0>  class Bar; end
=>  nil
irb(main):005:0>  Bar.new.foo
foo
=>  nil
irb(main):006:0>  quit

irb let me call foo which is non-sense.

[mkseo@uranus src]$ cat >  test.rb
def foo
  puts "foo"
end
class Bar; end
Bar.new.foo
[mkseo@uranus src]$ ruby test.rb
test.rb:5: private method `foo' called for #<Bar:0x2aaaaab00cc8> 
(NoMethodError)
[mkseo@uranus src]$

Ruby interpreter fails as expected.

So, here's my question. Why is irb running on its own interpreter(or
simulator or whatever)?


Sincerely,
Minkoo Seo
Thread:
Minkoo Seo
Ezra Zygmuntowicz
Minkoo Seo
Ezra Zygmuntowicz
Austin Ziegler
Minkoo Seo
Logan Capaldo
Mauricio Fernandez

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved