Skip to content

Instantly share code, notes, and snippets.

@mlomnicki
Created September 7, 2010 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlomnicki/569274 to your computer and use it in GitHub Desktop.
Save mlomnicki/569274 to your computer and use it in GitHub Desktop.
How to check how many arguments the method accepts
# How to check how many arguments the method accepts?
class Foo
def initialize
end
def bar(a,b)
end
def foo(&block)
end
def baz(*args)
end
end
%w[initialize bar foo baz].each do |method|
puts "#{method} has #{Foo.instance_method(method).arity} arguments"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment