[ruby-core:93960] [Ruby master Feature#5044] #zip with block return mapped results

From: foldes.laszlo2@...
Date: 2019-07-28 23:56:01 UTC
List: ruby-core #93960
Issue #5044 has been updated by karatedog (Fdes L疽zl鶇.


A workaround can be achieved with #then:

`[1,2,3].zip([1,2,3]).then { |a| a.map {|a,b| a+b} }`

Tested in Ruby 2.6.2p47.

----------------------------------------
Feature #5044: #zip with block return mapped results
https://bugs.ruby-lang.org/issues/5044#change-80151

* Author: trans (Thomas Sawyer)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
Is there any reason that #zip doesn't return results like map?

  [1,2,3].zip([1,2,3]){ |a,b| a + b }  #=> [2,4,6]

Currently, it just returns nil, which seems rather contrary to the return result of the non-block form.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next