Forum: Ruby on Rails IRB vs ruby-doc.org

Posted by John Merlino (johnmerlino)
on 2012-10-13 06:48
(Received via mailing list)
The ruby documentation says instance_variable_set is a public instance
method of Object:

http://ruby-doc.org/core-1.9.3/Object.html#method-...

And I believe it because you can call it on instances of Object:

1.9.3p0 :005 > Object.new.instance_variable_set :@a, 1
 => 1

It can't be a public instance method of Class or Module, because
otherwise the Object instance wouldnt have access to it, since the
above Object instance is an instance of Object, whose superclass is
BasicObject and that's it.

So my question is why when I launch IRB in Rails 3/Ruby 1.9.3, and
return as an array the instance methods of Object,
instance_variable_set is no where to be found:

1.9.3p0 :001 > Object.instance_methods(false)
 =>
[:psych_to_yaml, :to_yaml_properties, :to_yaml, :in?, :blank?, 
:present?, :presence, :acts_like?, :try, :html_safe?, :duplicable?, 
:to_param, :to_query, :`, :instance_values, :instance_variable_names, 
:to_json, :with_options, :as_json]

Shouldn't instance_variable_set be listed here?
Posted by Ignacio Piantanida (Guest)
on 2012-10-13 07:10
(Received via mailing list)
Object includes the Kernel module, which defines the 
:instance_variable_set
method

1.9.3p194 :001 > Kernel.instance_methods(false).include?
:instance_variable_set
 => true
1.9.3p194 :002 > Object.is_a? Kernel
 => true

2012/10/13 John Merlino <stoicism1@aol.com>

> It can't be a public instance method of Class or Module, because
> [:psych_to_yaml, :to_yaml_properties, :to_yaml, :in?, :blank?, :present?,
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


--
Piantanida, Ignacio Julin
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.