L
Li Chen
Hi all,
I wonder if the following code is the ruby way to implement
Integer#downto.
Thanks,
Li
#######################
class Integer
def my_downto(final=2)
for i in (final..self).to_a.reverse
yield i
end
end
end
10.my_downto(-1) do |i| puts i end
I wonder if the following code is the ruby way to implement
Integer#downto.
Thanks,
Li
#######################
class Integer
def my_downto(final=2)
for i in (final..self).to_a.reverse
yield i
end
end
end
10.my_downto(-1) do |i| puts i end