summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChashmeet Singh <chashmeetsingh@gmail.com>2015-10-05 17:51:23 +0530
committerChashmeet Singh <chashmeetsingh@gmail.com>2015-10-05 17:51:23 +0530
commitcae1960ca3a5c25d8db458234ac0a6e97ab87ed5 (patch)
tree439e482ab4e159e2b901d17d06b7a56b1cbc63ca
parente57fb68756ec6f4242ad04c359f7796606b52a42 (diff)
Reverse an array
-rw-r--r--ruby.html.markdown4
1 files changed, 4 insertions, 0 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 7bd28d86..4e8dcc8f 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -168,6 +168,10 @@ array[-1] #=> 5
# With a start index and length
array[2, 3] #=> [3, 4, 5]
+# Reverse an Array
+# array = [1,2,3]
+array.reverse #=> [3,2,1]
+
# Or with a range
array[1..3] #=> [2, 3, 4]