Skip to content

Instantly share code, notes, and snippets.

@nwxxb
Created June 29, 2024 11:36
Show Gist options
  • Select an option

  • Save nwxxb/f216f2150401bfef3172a091a15409cd to your computer and use it in GitHub Desktop.

Select an option

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
# 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