[#83107] Alias Enumerable#include? to Enumerable#includes? — Alberto Almagro <albertoalmagro@...>

Hello,

9 messages 2017/10/04

[ruby-core:83237] [Ruby trunk Bug#14008] Adding elements to array inside 2D array duplicates across all other arrays

From: sameer.deshmukh93@...
Date: 2017-10-12 13:40:54 UTC
List: ruby-core #83237
Issue #14008 has been reported by v0dro (Sameer Deshmukh).

----------------------------------------
Bug #14008: Adding elements to array inside 2D array duplicates across all other arrays
https://bugs.ruby-lang.org/issues/14008

* Author: v0dro (Sameer Deshmukh)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Say I create a 2D array in Ruby using the Array.new syntax like this:
arr = Array.new 3, []

Adding elements to say, the 2nd array inside `arr` produces the following result:

~~~ ruby
arr = Array.new 3, []
arr[2] << 3
arr
# => [[3], [3], [3]]
~~~

### Expected behavior
I think this should work exactly like what happens when initializing 2D arrays using the literal syntax:

~~~ ruby
arr = [[],[],[]] 
arr[2] << 3
arr
# => [[], [], [3]] 
~~~~



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

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next