Skip to content

Instantly share code, notes, and snippets.

@bryanwoods
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanwoods/dbd8c77712a2d4a654b5 to your computer and use it in GitHub Desktop.
Save bryanwoods/dbd8c77712a2d4a654b5 to your computer and use it in GitHub Desktop.
# 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