Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created April 17, 2014 16:08
Show Gist options
  • Save havenwood/bb5fe5a5056dcaebac87 to your computer and use it in GitHub Desktop.
Save havenwood/bb5fe5a5056dcaebac87 to your computer and use it in GitHub Desktop.
Strings (IRC)
##
# Interpolation
example = 'birds'
'#{example}'
#=> "\#{example}"
"#{example}"
#=> "birds"
%(#{example})
#=> "birds"
##
# Backslashes
'\n'
#=> "\\n" # Note that this is not a newline, but a backslash then an "n".
"\n"
#=> "\n" # These are newlines.
%(\n)
#=> "\n"
##
# A double quote in a String
'"'
#=> "\"" # The backslash is an escape, only a double quote is in the String.
"\"" # You need to escape a double quote inside double quotes.
#=> "\""
%(")
#=> "\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment