Last active
August 29, 2015 14:01
-
-
Save bryanwoods/dbd8c77712a2d4a654b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# irb... | |
# Numbers | |
3 + 2 | |
# Strings | |
puts "Hi, everybody!" | |
# Booleans | |
true | |
false | |
nil | |
# Variables | |
x = 100 | |
puts x | |
# Math | |
# Addition (+) | |
# Subtraction (-) | |
# Multiplication (*) | |
# Division (/) | |
# Exponentiation (**) (raises one number to the power of the other) | |
# Modulo (%) (returns the remainder after division) | |
1 + 2 | |
3 - 5 | |
3 * 3 | |
9 / 3 | |
3 ** 2 | |
21 % 7 | |
# Puts and print | |
puts "Yo what's your name?" | |
print "Um...Bryan" | |
# Methods | |
"I love gin...gin gin gin".length | |
# You call methods with a `.`. | |
# `length` is a method all strings in Ruby have. It returns the string's | |
# length. | |
"Bryan".length | |
"Bryan".reverse | |
puts "bryan".upcase | |
puts "BRYAN".downcase | |
# Comments | |
# I'm a comment | |
3 + 2 # 5!! | |
# Local variables are lowercase and snakecase | |
name = "Bryan" | |
puts "Hi my name is #{name}" | |
my_name = "Bryan" | |
my_age = 29 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment