class Fixnum def double_upto(stop) x = self until x > stop yield x x = x * 2 end endend10.double_upto(50) { |x| puts x }# 10# 20# 40