instance method
Object#instance_variables
() -> ::Array[::Symbol]
obj.instance_variables → array
object.c
View on GitHub ↗
VALUE
rb_obj_instance_variables(VALUE obj)
{
VALUE ary;
ary = rb_ary_new();
rb_ivar_foreach(obj, ivar_i, ary);
return ary;
}
Returns an array of instance variable names for the receiver. Note that simply defining an accessor does not create the corresponding instance variable.
Example
class Fred attr_accessor :a1 def initialize @iv = 3 end end Fred.new.instance_variables #=> [:@iv]
See also
#instance_variable_get
#instance_variable_set
#instance_variable_defined?
#is_a?
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0