Alex Rivera | Logout

How can I check if an object with specific property exists in a Ruby array

Asked 2012-07-07T16:28:30.417
28

I have an array of objects *and the object looks something *like this {seat_id, room_id, date_created};
I want to find if in that array there is an object which has seat_id equal to a specific value. How can I do that?

Edit
Report

1 Answer

1
arr.map{|a| a.seat_id == "value"}

It will return array of true and false value, true value are matching value.

answered 2012-07-14T11:46:42.553

Your Answer