On Tue, Dec 7, 2010 at 5:56 AM, Matt Slay <mattslay / jordanmachine.com> wrote:
>> x = @tolerance2.send(@size[2])
>
> Thanks, Robert, this does work fine....
>
> However, in further studies on this topic, I have stumbled across the
> .attributes() method, which seems like a more sensibly named thing to
> see in code, and appears to accomplish the same thing.
>
> x = @tolerance2.attributes[@size[2]]
>
> Any reason that one is better than the other in my case. I can see that
> send() can even call a method, and that could be useful, but in this
> case, I am specifically looking for an attribute value by it's name.

I would prefer

 > x = @tolerance2.send(@size[2])

because that will only calculate that one value. Whereas

 > x = @tolerance2.attributes[@size[2]]

will first prepare an entire hash with all "attributes" and then you will
only use 1 of those results and leave the rest unused, Which seems
wasting of CPU cycles to me. E.g. try

> puts @tolerance2.attributes.inspect

to see what that means. In other cases though, the 'attributes' function can
be very useful, e.g. if you want to process the entire set of
attributes together
as a hash.

HTH,

Peter