Method: Object#instance_variables
- Defined in:
- variable.c
#instance_variables ⇒ Array
Returns an array of instance variable names for the receiver. Note that simply defining an accessor does not create the corresponding instance variable.
class Fred
attr_accessor :a1
def initialize
@iv = 3
end
end
Fred.new.instance_variables #=> [:@iv]
1578 1579 1580 1581 1582 1583 1584 1585 1586 |
# File 'variable.c', line 1578
VALUE
rb_obj_instance_variables(VALUE obj)
{
VALUE ary;
ary = rb_ary_new();
rb_ivar_foreach(obj, ivar_i, ary);
return ary;
}
|