cours0708/P5B/ruby/exercices/class_Impair.rb

19 lines
181 B
Ruby
Raw Normal View History

2008-11-25 21:11:16 +00:00
class Impairs
def initialize(n)
@cardinal = n
end
def each
i = 1
@cardinal.times do
yield i
i = i + 2
end
end
end
Impairs.new(3).each do | i |
puts i.to_s
end