Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个对象数组*并且该对象看起来像这样{seat_id, room_id, date_created}; 我想查找在该数组中是否有一个对象其 seat_id 等于特定值。我怎样才能做到这一点?
{seat_id, room_id, date_created};
arr.any?{|a| a.seat_id == "value"}
这里:
arr.find_index {|item| item.seat_id == other.seat_id}
arr.map{|a| a.seat_id == "value"}
它将返回真假值数组,真值是匹配值。