Created
September 7, 2010 22:35
-
-
Save mlomnicki/569274 to your computer and use it in GitHub Desktop.
How to check how many arguments the method accepts
This file contains 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
# 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