Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special handling for Array#zip #60

Open
mame opened this issue Oct 13, 2021 · 0 comments
Open

Special handling for Array#zip #60

mame opened this issue Oct 13, 2021 · 0 comments

Comments

@mame
Copy link
Member

mame commented Oct 13, 2021

It is useful to keep the elements of Array#zip as tuples. RBS of Array#zip has less information for the behavior, so it would be good to implement it as a built-in method.

as = [1, 2, 3]
bs = %w(a b c)

p as.zip(bs)
#=> expected: Array[[Integer, String]] (or [Integer, String?])
#   actual:   Array[Array[(Integer | String)?]]

as.zip(bs) do |a, b|
  p a #=> expected: Integer
      #   actual: (Integer | String)?
  p b #=> expected: String (or String?)
      #   actual: (Integer | String)?
end

cs = [1.0, 2.0, 3.0]

as.zip(bs, cs) do |a, b, c|
  p a #=> expected: Integer
      #   actual: untyped
  p b #=> expected: String (or String?)
      #   actual: untyped
  p c #=> expected: Float (or Float?)
      #   actual: untyped
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant