summaryrefslogtreecommitdiffhomepage
path: root/ruby.html.markdown
diff options
context:
space:
mode:
authorDivay Prakash <divayprakash@users.noreply.github.com>2018-10-04 22:00:09 +0530
committerGitHub <noreply@github.com>2018-10-04 22:00:09 +0530
commite867dfd7b6eee67b2205e243027f8a4eb40a6681 (patch)
tree706ff0bbc4afc7fac715f700f56be8550e8cd66d /ruby.html.markdown
parentb89b6a55ed4d739ea2098833638237ac0c364a13 (diff)
parentc3c6e3b08d9129d52a7349d0656569022ffa2f9b (diff)
Merge pull request #3253 from kaymmm/fix3042
[ruby/en] fixes #3042 (spring cleanup)
Diffstat (limited to 'ruby.html.markdown')
-rw-r--r--ruby.html.markdown12
1 files changed, 8 insertions, 4 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 2f4d0934..2635309b 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -17,6 +17,7 @@ contributors:
- ["Jake Faris", "https://github.com/farisj"]
- ["Corey Ward", "https://github.com/coreyward"]
- ["Jannik Siebert", "https://github.com/janniks"]
+ - ["Keith Miyake", "https://github.com/kaymmm"]
---
```ruby
@@ -83,9 +84,9 @@ false.class #=> FalseClass
# Combined comparison operator (returns `1` when the first argument is greater,
# `-1` when the second argument is greater, and `0` otherwise)
-1 <=> 10 #=> -1
-10 <=> 1 #=> 1
-1 <=> 1 #=> 0
+1 <=> 10 #=> -1 (1 < 10)
+10 <=> 1 #=> 1 (10 > 1)
+1 <=> 1 #=> 0 (1 == 1)
# Logical operators
true && false #=> false
@@ -188,8 +189,11 @@ array[2, 3] #=> [3, 4, 5]
array[1..3] #=> [2, 3, 4]
# You can reverse an Array.
+# Return a new array with reversed values
+[1,2,3].reverse #=> [3,2,1]
+# Reverse an array in place to update variable with reversed values
a = [1,2,3]
-a.reverse! #=> [3,2,1]
+a.reverse! #=> a==[3,2,1] because of the bang ('!') call to reverse
# Like arithmetic, [var] access is just syntactic sugar
# for calling a method '[]' on an object.