obj.instance_variable_defined?(symbol) â true or false
Instance Public methods
Returns true
if the given instance variable is defined in
obj.
class Fred def initialize(p1, p2) @a, @b = p1, p2 end end fred = Fred.new('cat', 99) fred.instance_variable_defined?(:@a) #=> true fred.instance_variable_defined?("@b") #=> true fred.instance_variable_defined?("@c") #=> false
Please login to continue.