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??
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??
Pat K. 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 W.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs