rbs icon indicating copy to clipboard operation
rbs copied to clipboard

inherit signature from another method

Open HoneyryderChuck opened this issue 5 years ago • 2 comments

A pattern used a bit in the wild is the delegation of arguments to another method:

def perform(*args)
  # log things, activate gear
  do_perform(*args)
end

def do_perform(key, value, description)
   ....

Considering that add typing info to do_perform is straightforward, how could I hint in rbs that perform has the same signature? If not, does it make sense to have such a feature?

HoneyryderChuck avatar Oct 16 '20 16:10 HoneyryderChuck

I believe tou can use alias perform do_perform

marcandre avatar Oct 16 '20 18:10 marcandre

You can do that if they have exactly the same method types.

I know there are cases you want to add/remove arguments, but it cannot be done with RBS now. (You have to write two defs with the types (almost) duplicated.)

soutaro avatar Oct 17 '20 07:10 soutaro