Skip to content

Instantly share code, notes, and snippets.

@yancya
Created July 4, 2018 11:32
Show Gist options
  • Save yancya/f1f1fa747f16c166db06c3332153b3e7 to your computer and use it in GitHub Desktop.
Save yancya/f1f1fa747f16c166db06c3332153b3e7 to your computer and use it in GitHub Desktop.
class Array
def +@
false
end
end
class TrueClass
def +(o)
to_s + o.join(',')
end
end
class FalseClass
def +(o)
to_s + o.join(',')
end
end
class String
def +(o)
[self, o.to_s].join
end
end
p !+[] #=> true
p !+[]+[] #=> "true"
p !+[]+[]+![] #=> "truefalse"
p (!+[]+[]+![]).length #=> 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment