Flowdock
instance_variable_set(ivarname, value) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Show source
Register or log in to add new notes.
November 18, 2009 - (>= v1_8_6_287)
5 thanks

Example

code:

class Klass
  def set(string)
    var_name = "@#{string}"  # the '@' is required
    self.instance_variable_set(var_name, 'bar')
  end
  def puts_foo
    puts @foo
  end
end
k = Klass.new
k.puts_foo  # nil
k.set('foo')
k.puts_foo  # 'bar'