Last active
August 29, 2015 14:17
-
-
Save robertodecurnex/f75560003662589934db to your computer and use it in GitHub Desktop.
Having Fun With Unicode and String Literals
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
puts <<THIS_IS_A_HEREDOC | |
And this is the content of the heredoc. | |
It's obviously multi-line. | |
And it's great for creating help messages and things like that. | |
THIS_IS_A_HEREDOC | |
#=> And this is the content of the heredoc. | |
# It's obviously multi-line. | |
# And it's great for creating help messages and things like that. |
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
<<DOWNCASE.upercase | |
lowercase to uppercase | |
DOWNCASE | |
#=> "LOWERCASE TO UPPERCASE" | |
<<FIRST + <<SECOND | |
One | |
FIRST | |
Two | |
SECOND | |
#=> " One\n Two\n" | |
puts <<ORIGINAL.sub(<<MATCH, <<SUBSTITUTION) | |
This is the original string. | |
I would want to change this line. | |
This is neat. | |
ORIGINAL | |
I would want to change this line. | |
MATCH | |
Modified by #sub. | |
SUBSTITUTION | |
#=> This is the original string. | |
# Modified by #sub. | |
# This is neat. |
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
# encoding: UTF-8 | |
😁 = 'smile' | |
<<LETS[0..-2] + 😁 + <<FACE | |
Let's put a | |
LETS | |
on that face | |
FACE | |
#=> "Let's put a smile on that face" |
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
def 😁 | |
puts "Smile!" | |
end | |
😁 #=> Smile! | |
#Some Valid Method Names | |
# ° | |
# + | |
# 😸 | |
# -@ | |
# ~ |
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
😸 = 'cat' | |
❄ = 'snowflake' | |
© = 'copyright' | |
7⃣ = 7 | |
3⃣ = 3 | |
7⃣ + 3⃣ #=> 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment