The ruby documentation says instance_variable_set is a public instance
method of Object:
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?