for i in 0..5
print i
end
it show me '012345'.
and then I want to show '543210' and I try.
for i in 5..0
print i
end
it doesn't work :'(.
how can I do it??
···
--
Posted via http://www.ruby-forum.com/.
for i in 0..5
print i
end
it show me '012345'.
and then I want to show '543210' and I try.
for i in 5..0
print i
end
it doesn't work :'(.
how can I do it??
--
Posted via http://www.ruby-forum.com/.
Pat Kiatchaipipat wrote:
for i in 0..5
print i
end
For loops are not very rubyish. Please use an internal iterator instead. For example:
(0..5).each { |i| print i }
or
0.upto(5) { |i| print i }
or
6.times { |i| print i }
it show me '012345'.
and then I want to show '543210' and I try.for i in 5..0
print i
endit doesn't work :'(.
how can I do it??
5.downto(0) { |i| print i }
Best regards,
Jari Williamsson