[Rails] IRB vs ruby-doc.org
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-i-instance_variable_set
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?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home