If I have two variables like a and h.
a = ["cat", "dog", "mat"]
h = {cat: 'gatto', dog: 'cane', mat: 'stuoia'} # (Italian translations)
And I call the method .each on them, if I don’t know the kind of object they are pointing to, how can I know that the block passed to a.each can take one parameter and the block passed to b.each can take two?
In other words, when I pass a block to a method, how can I know how many block parameters the method will set?
Is there some_method which returns the number of parameters a block should take? So that obj.general_method_that_takes_a_block.some_method would return the number of parameters that general_method_that_takes_a_block passes to its block?
A straightforward way is: