= Converter.new converter.degree_to_farenheit(30) class Converter def degree_to_farenheit(degree) return degree * 1.8 + 32 end end class Converter def degree_to_farenheit(degree) degree * 1.8 + 32 end end
Integer def times(&block) ! ! ! end end class Integer def times(&block) for n in [1..self] ! end end end class Integer def times(&block) for n in [1..self] block.call end end end
end end class Integer def times(&block) for n in [1..self] block.call(n) end end end 5.times do print “Hello world” print “Number of calls: #{…}” end 5.times do |n| print “Hello world” print “Number of calls: #{…}” end 5.times do |n| print “Hello world” print “Number of calls: #{n}” end
include Enumerable ! ! ! ! end class Set include Enumerable ! def each(&block) collection.each(&block) end end people = Set.new(array) ! people.any? people.find { |person| ... } people.include?(...) people.select { |person| ... }