Skip to content

Instantly share code, notes, and snippets.

@robertodecurnex
Last active August 29, 2015 14:17
Show Gist options
  • Save robertodecurnex/f75560003662589934db to your computer and use it in GitHub Desktop.
Save robertodecurnex/f75560003662589934db to your computer and use it in GitHub Desktop.
Having Fun With Unicode and String Literals
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.
<<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.
# 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"
def 😁
puts "Smile!"
end
😁 #=> Smile!
#Some Valid Method Names
# °
# +
# 😸
# -@
# ~
😸 = '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