Last active
July 25, 2017 17:40
-
-
Save drbrain/e4ab170a9ac31d88f3ab to your computer and use it in GitHub Desktop.
A method that has a default argument that defines a method that contains a here-document
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 a l = def b; <<-NIGHTMARES; end; puts send l; end | |
😱😱😱 | |
NIGHTMARES | |
a |
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
$ ruby nightmares.rb | |
😱😱😱 |
As written, the output is:
"ruby: No such file or directory -- t.rb (LoadError)"
:-)
I'd forgotten, btw, that def
returns a value. Thanks for the reminder.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A totem pole:
Smokey the bear