summaryrefslogtreecommitdiffhomepage
path: root/ruby.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'ruby.html.markdown')
-rw-r--r--ruby.html.markdown14
1 files changed, 12 insertions, 2 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 4e9f8aee..782ffc4c 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -42,13 +42,18 @@ You shouldn't either
2**5 #=> 32
5 % 3 #=> 2
+# Bitwise operators
+3 & 5 #=> 1
+3 | 5 #=> 7
+3 ^ 5 #=> 6
+
# Arithmetic is just syntactic sugar
# for calling a method on an object
1.+(3) #=> 4
10.* 5 #=> 50
# Special values are objects
-nil # Nothing to see here
+nil # equivalent to null in other languages
true # truth
false # falsehood
@@ -76,6 +81,11 @@ false.class #=> FalseClass
2 <= 2 #=> true
2 >= 2 #=> true
+# Combined comparison operator
+1 <=> 10 #=> -1
+10 <=> 1 #=> 1
+1 <=> 1 #=> 0
+
# Logical operators
true && false #=> false
true || false #=> true
@@ -121,7 +131,7 @@ puts "I'm printing!"
# print to the output without a newline
print "I'm printing!"
-#=> I'm printing! => nill
+#=> I'm printing! => nil
# Variables
x = 25 #=> 25