Getting varname, changing array set/get

Hello
How can I get the name of the object (self)?
x=[1,2,3]; y[0]=x; y[0].name # => :x

I want to modify setting and getting of array-elements,
e.g. to store x**2 and to get sqrt(x), if so uses special array-names
/^two_.*/
(This is just an example)
Which methods to change? Is that possible in Ruby?
idea: overwrite Array.new: if objectmame matches, add math+super to
object.which_methods???

thanks
Berg

Hello
How can I get the name of the object (self)?
x=[1,2,3]; y[0]=x; y[0].name # => :x

You can't. Btw. this has been discussed numerous times before - even
years ago. The 5s explanation is that there can be unlimited number of
references to an object thus _the_ name does not exist.

I want to modify setting and getting of array-elements,
e.g. to store x**2 and to get sqrt(x), if so uses special array-names
/^two_.*/
(This is just an example)
Which methods to change? Is that possible in Ruby?
idea: overwrite Array.new: if objectmame matches, add math+super to
object.which_methods???

Use a Hash, Luke - and not local variables. :wink:

Kind regards

robert

ยทยทยท

On Wed, Feb 3, 2016 at 2:29 PM, A Berger <aberger7890@gmail.com> wrote:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/