Mapping an object

Hi,

This is Harnish. I am looking for a way to map an object.

Ex:

Instead of doing,

resultset = A.get_arr
result = resultset[0].my_obj

Can I combine the 2 statements into 1 when I know that my A.get_arr is
sure to return an array with just 1 object.

Thanks for your help.

Regards,
Harnish

On 10/4/07, Harnish B. [email protected] wrote:

Instead of doing,

resultset = A.get_arr
result = resultset[0].my_obj

Can I combine the 2 statements into 1 when I know that my A.get_arr is
sure to return an array with just 1 object.

I think your code could just become:
result = A.get_arr[0].my_obj

Consider this:
irb(main):002:0> def foo; [“foo”]; end
=> nil
irb(main):003:0> foo[0].reverse
=> “oof”

Hope that helps,
-Harold

Quoth Harnish B.:

Can I combine the 2 statements into 1 when I know that my A.get_arr is
sure to return an array with just 1 object.

Thanks for your help.

Regards,
Harnish

result = A.get_arr.first # => First object of A.get_arr’s array.