I have a class with a method register(key, val). I am trying to add key as a instance variable of the class and set it equal to val. Right now I'm trying to use self.instance_variable_set(':@' + key, val) but I'm getting this error:
in `instance_variable_set': `:@table' is not allowed as an instance variable name (NameError)
I am calling register('table', {'key' => 'value'})
Any idea how to do this properly? Thanks!
self" this makes very little sense to me.selfcan reference aClassjust as it can reference an instance of aClassand if we are being technical about this all methods areinstance_methodsbecause everything is an instance.