summaryrefslogtreecommitdiffhomepage
path: root/ruby.html.markdown
diff options
context:
space:
mode:
authorChashmeet Singh <chashmeetsingh@gmail.com>2015-10-05 20:22:07 +0530
committerChashmeet Singh <chashmeetsingh@gmail.com>2015-10-05 20:22:07 +0530
commit51e3bd21e29ac19884eca57c6f4f1defbd78ea3a (patch)
tree08b975e3467aa436a86b3e83047b09a8fc7e121b /ruby.html.markdown
parentcae1960ca3a5c25d8db458234ac0a6e97ab87ed5 (diff)
Reverse a list
Diffstat (limited to 'ruby.html.markdown')
-rw-r--r--ruby.html.markdown4
1 files changed, 2 insertions, 2 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 4e8dcc8f..b6d0e44d 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -169,8 +169,8 @@ array[-1] #=> 5
array[2, 3] #=> [3, 4, 5]
# Reverse an Array
-# array = [1,2,3]
-array.reverse #=> [3,2,1]
+a=[1,2,3]
+a[::-1] #=> [3,2,1]
# Or with a range
array[1..3] #=> [2, 3, 4]