S
Simon Strandgaard
We already have pad with nils
irb(main):001:0> (4..6).zip(nil)
=> [[4, nil], [5, nil], [6, nil]]
It would be awesome if #zip could do the same
with non-nil elements.. (this is what I propose)
p (4..6).zip('a')
#=> [[4, "a"], [5, "a"], [6, "a"]]
p (4..6).zip('a', 'b')
#=> [[4, "a", "b"], [5, "a", "b"], [6, "a", "b"]]
However this is not the way it works at the moment,
so that behavier would need to be abandoned.
Which I consider weird and restrictive.. agree?
irb(main):002:0> (4..6).zip('a')
=> [[4, "a"], [5, nil], [6, nil]]
irb(main):003:0> (4..6).zip('a', 'b')
=> [[4, "a", "b"], [5, nil, nil], [6, nil, nil]]
#zip behaves nice when you pass it an Array.
irb(main):004:0> (4..6).zip(['a', 'b'])
=> [[4, "a"], [5, "b"], [6, nil]]
irb(main):005:0>
BTW: (4..6).zip #=> [[4], [5], [6]]
Cool ;-)
irb(main):001:0> (4..6).zip(nil)
=> [[4, nil], [5, nil], [6, nil]]
It would be awesome if #zip could do the same
with non-nil elements.. (this is what I propose)
p (4..6).zip('a')
#=> [[4, "a"], [5, "a"], [6, "a"]]
p (4..6).zip('a', 'b')
#=> [[4, "a", "b"], [5, "a", "b"], [6, "a", "b"]]
However this is not the way it works at the moment,
so that behavier would need to be abandoned.
Which I consider weird and restrictive.. agree?
irb(main):002:0> (4..6).zip('a')
=> [[4, "a"], [5, nil], [6, nil]]
irb(main):003:0> (4..6).zip('a', 'b')
=> [[4, "a", "b"], [5, nil, nil], [6, nil, nil]]
#zip behaves nice when you pass it an Array.
irb(main):004:0> (4..6).zip(['a', 'b'])
=> [[4, "a"], [5, "b"], [6, nil]]
irb(main):005:0>
BTW: (4..6).zip #=> [[4], [5], [6]]
Cool ;-)