mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Reverse an array
This commit is contained in:
parent
51e3bd21e2
commit
0beb78ac43
@ -170,7 +170,7 @@ array[2, 3] #=> [3, 4, 5]
|
||||
|
||||
# Reverse an Array
|
||||
a=[1,2,3]
|
||||
a[::-1] #=> [3,2,1]
|
||||
a.reverse! #=> [3,2,1]
|
||||
|
||||
# Or with a range
|
||||
array[1..3] #=> [2, 3, 4]
|
||||
|
Loading…
Reference in New Issue
Block a user