Compare object attributes with array of objects Ruby on Rails -


i have object want compare array of objects. if 2 specific attributes equal want stop loop. how can that, or how can in better rails way?

@item #item compare           @items.each |item|             if ( (item.att1 == @item.att1) && (item.att3 == @item.att3) )                  is_equal(item.id)              else                 #do             end         end 

use find method of array:

matched_item = @items.find { | item | item.att1 == @item.att1 && item.att1 == @item.att1 } is_equal(matched_item.id) 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -