Forum: Ruby Re: reverse indexing (was RE: Ruby and WMI)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
botp (Guest)
on 2005-11-23 11:58
(Received via mailing list)
Sean O'Halpin [mailto:removed_email_address@domain.invalid]:

#Did you know you can use reverse_each?

of course, there is even _each_ :)

but i am suggesting this:

x=[0,1,2,3,4,5]	=>[1,2,3,4,5]
x[-1..-6]	=>[5,4,3,2,1]
x[-3..-4]	=>[3,2]

right now, the above return empty [].

kind regards -botp

#
#x = (0..5).to_a
#x.reverse_each do |i|
#  print i
#end
##=> 54321
#
#Regards,
#
#Sean
#
#
This topic is locked and can not be replied to.