How can you iterate through an array of objects and return the entire object if a certain attribute is correct?
I have the following in my rails app
array_of_objects.each { |favor| favor.completed == false }
array_of_objects.each { |favor| favor.completed }
but for some reason these two return the same result! I have tried to replace each
with collect
, map
, keep_if
as well as !favor.completed
instead of favor.completed == false
and none of them worked!
Any help is highly appreciated!
favor
iffavor.completed
and if!favor.completed
each
method always returns the original array.true
? Or evaluates 'false'?