Skip to content

Instantly share code, notes, and snippets.

@cciollaro
Last active December 17, 2015 07:29
Show Gist options
  • Save cciollaro/5573112 to your computer and use it in GitHub Desktop.
Save cciollaro/5573112 to your computer and use it in GitHub Desktop.
Method definition for a wildcard method. You never know what you're gonna get. Example usage: 27.random_method
class Object
def random_method
begin
method = self.methods.sample.to_s
print "Calling #{method}: "
return_val = self.instance_eval(method)
puts return_val
rescue Exception => e
puts "it failed (#{e.message})"
retry
end
return return_val
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment