Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Last active December 21, 2015 18:39
Show Gist options
  • Save jendiamond/6348652 to your computer and use it in GitHub Desktop.
Save jendiamond/6348652 to your computer and use it in GitHub Desktop.
Exercise 10 - Learn Ruby the Hard Way
# the variable tabby_cat is assigned the value of the string;
# the \t (backslash t) tabs the line in
tabby_cat = "\tI'm tabbed in."
# the variable persian_cat is assigned the value of the string;
# the \n (backslash n) puts the rest of the string on a new line
persian_cat = "I'm split \non a line."
# the variable backslash_cat is assigned the value of the string;
# the \\ (backslash backslash) prints a backslash character
backslash_cat = "I'm \\ a \\ cat."
# the variable fat_cat is assigned the value of the list MY_HEREDOC;
# This is a HEREDOC. The << symbol with a name written in uppercase acts like the <<PARAGRAPH you can write as many lines as you want in between
fat_cat = <<MY_HEREDOC
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
MY_HEREDOC
# the puts method prints the variables
puts tabby_cat
puts persian_cat
puts backslash_cat
puts fat_cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment