-
-
Save havenwood/bb5fe5a5056dcaebac87 to your computer and use it in GitHub Desktop.
Strings (IRC)
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
## | |
# 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