Created
June 29, 2024 11:36
-
-
Save nwxxb/f216f2150401bfef3172a091a15409cd to your computer and use it in GitHub Desktop.
try to make this meme (I forget the origin) of hello world into reality
This file contains hidden or 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
| # basic hello world | |
| puts "hello world" | |
| # inversed hello world | |
| def hello_world(method_sym) | |
| if self.respond_to?(method_sym, true) | |
| self.send(method_sym, 'hello world') | |
| else | |
| 'hello world'.send(method_sym) | |
| end | |
| end | |
| hello_world(:print) | |
| hello_world(:puts) | |
| hello_world(:p) | |
| require 'prettyprint' | |
| hello_world(:pp) | |
| # or you can do... | |
| puts hello_world(:upcase) | |
| puts hello_world(:split) | |
| puts hello_world(:reverse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment