Ruby can do that.
$ ruby
def method_missing(method_name, *args, &block)
# Check if the missing method call has a single string argument
if args.length == 1 && args.first.is_a?(String)
intended_method = args.first.to_sym
# Check if this intended method exists (such as Kernel's puts or print)
if respond_to?(intended_method, true)
# Invoke the intended method with the method name's string
return send(intended_method, method_name.to_s)
end
end
# Pass to super for normal NoMethodError handling if the pattern doesn't match
super
end
# Example usage:
HelloWorld("puts") # Output: HelloWorld
-:1: warning: redefining Object#method_missing may cause infinite loop
HelloWorld