Robot Has No Heart

Xavier Shay blogs here

A robot that does not have a heart

Eating with functions

1
2
3
4
5
6
7
8
9
# 3 Tasty treats, all the same!
edibles.each do |edible|
  edible.eat! if likes?(edible) || edible.is_healthy?
end

condition = lambda {|edible| likes?(edible) || edible.is_healthy?}
edibles.select(&condition).each(&:eat!)

edibles.select(disjoin(&method(:likes?), &:is_healthy?)).each(&:eat!)

Help: &:eat!, disjoin

A pretty flower Another pretty flower