[ruby-core:90685] [Ruby trunk Bug#15455] In v2.6.0 the return value of `each_with_object` and `each_object` is truncated when the object is a hash.

From: cary@...
Date: 2018-12-23 19:55:48 UTC
List: ruby-core #90685
Issue #15455 has been reported by CaryInVictoria (Cary Swoveland).

----------------------------------------
Bug #15455: In v2.6.0 the return value of `each_with_object` and `each_object` is truncated when the object is a hash.
https://bugs.ruby-lang.org/issues/15455

* Author: CaryInVictoria (Cary Swoveland)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
 RUBY VERSION: 2.6.0 (2018-12-23 patchlevel -1)

`a = [1, 2, 3]`

`a.each_with_object([])    #=> #<Enumerator: [1, 2, 3]:each_with_object([])>
a.each_with_object(1..3)   #=> #<Enumerator: [1, 2, 3]:each_with_object(1..3)>
a.each_with_object("cat") #=> #<Enumerator: [1, 2, 3]:each_with_object("cat")>`

So far so good. But there is a problem with the object is a hash.
 
`a.each_with_object({}) #=> #<Enumerator: [1, 2, 3]:each_with_objec)>
a.each_with_object(Hash.new(0)) #=> #<Enumerator: [1, 2, 3]:each_with_objec)>
a.each.with_object(Hash.new(0)) #=> #<Enumerator: #<Enumerator: [1, 2, 3]:each>:with_objec)>`

This problem does not occur with v2.5.3.



-- 
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