rbs icon indicating copy to clipboard operation
rbs copied to clipboard

How can we write `Array#zip` with arbitrary number of arguments?

Open mame opened this issue 6 years ago • 1 comments

The current signature for Array#zip accepts exactly one array argument, but the actual zip acceptes one or more arrays. Can we write a signature for this?

pp [1, 2, 3].zip(%w(foo bar baz), [:foo, :bar, :baz])
#=> [[1, "foo", :foo], [2, "bar", :bar], [3, "baz", :baz]]

mame avatar Aug 09 '19 08:08 mame

I imagine this can be closed now?

If I'm not mistaken, it should look like:

def zip: (*Array[untyped]) -> Array[Array[untyped]]
       | (*Array[untyped]) { (Array[untyped]) -> void } -> nil

Right? It's my first rbs signature 😅

marcandre avatar Oct 11 '20 04:10 marcandre