Skip to content

Instantly share code, notes, and snippets.

@284km
Last active May 17, 2019 10:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 284km/1e5f105b810d5887064ddbb02f143771 to your computer and use it in GitHub Desktop.
Save 284km/1e5f105b810d5887064ddbb02f143771 to your computer and use it in GitHub Desktop.
class String
# def to_proc
def* to_proc
puts self
-> { self }
end
end
->(&b){b.()}.(&("Hello world" * 42))
# It was a wonderful puzzle! Many thanks!
# I had the following experiences:)
# First of all, I did my best to make 1 with 4 and 2.
# "4*2", "4%2", "4.2"? I realized soon that this was impossible...
# Next, I thought that how can I destroy "* 42"? how can I destroy "* 42"? how can I destroy "* 42"?
# And I thought about the redefinition of the method as one way.
# I kept thinking. Let's redefine the asterisk! And write "def *". At that time,
# oh? Can I discard "42" as an argument? ( ゚д゚)ハッ! I can discard "42" as an argument!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment