[#85940] [Ruby trunk Bug#14578] Forking a child process inside of a mutex crashes the ruby interpreter — ben.govero@...
Issue #14578 has been reported by bengovero (Ben Govero).
3 messages
2018/03/05
[#86205] [Ruby trunk Feature#14618] Add display width method to String for CLI — aycabta@...
Issue #14618 has been reported by aycabta (aycabta .).
3 messages
2018/03/19
[#86366] Re: [ruby-cvs:70102] usa:r63008 (trunk): get rid of test error/failure on Windows introduced at r62955 — Eric Wong <normalperson@...>
usa@ruby-lang.org wrote:
3 messages
2018/03/28
[ruby-core:86373] [Ruby trunk Bug#14641][Rejected] Shouldn't Array#map not modify its array?
From:
merch-redmine@...
Date:
2018-03-28 22:01:27 UTC
List:
ruby-core #86373
Issue #14641 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Rejected
The array itself is not modified, you are mutating elements of the current array during iteration (as String#<< mutates the receiver), then returning a new array with the mutated elements (since String#<< returns the receiver). If you don't want to mutate the elements, use String#+:
~~~ ruby
irb(main):001:0> a = ['a', 'b']
=> ["a", "b"]
irb(main):002:0> a.map{|e| e + 'c'}
=> ["ac", "bc"]
irb(main):003:0> a
=> ["a", "b"]
irb(main):004:0> a.object_id
=> 11790377160340
irb(main):005:0> a.map{|e| e << 'c'}.object_id
=> 11788696580840
~~~
----------------------------------------
Bug #14641: Shouldn't Array#map not modify its array?
https://bugs.ruby-lang.org/issues/14641#change-71297
* Author: hartator (Julien Khaleghy)
* Status: Rejected
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.5.0 and 2.4.2
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hi,
Thanks for the awesome work you guys have been doing on Ruby for all this years.
I might be missing something obvious, but I thought Array#map doesn't modify the array it's called on?
Ie.
~~~ ruby
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
a = ['a','b']
..
=> ["a", "b"]
a.map{|e| e << 'c'}
=> ["ac", "bc"]
a.map{|e| e << 'c'}
=> ["acc", "bcc"]
a.map{|e| e << 'c'}
=> ["accc", "bccc"]
a.map{|e| e << 'c'}
=> ["acccc", "bcccc"]
a
=> ["acccc", "bcccc"]
~~~
Expected `a` to be still ["a", "b"].
Same in Ruby 2.4 ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
~~~ ruby
irb(main):003:0* a = ['a','b']
=> ["a", "b"]
irb(main):004:0> a.map{|e| e << 'c'}
=> ["ac", "bc"]
irb(main):005:0> a.map{|e| e << 'c'}
=> ["acc", "bcc"]
irb(main):006:0> a.map{|e| e << 'c'}
=> ["accc", "bccc"]
irb(main):007:0> a.map{|e| e << 'c'}
=> ["acccc", "bcccc"]
irb(main):008:0> a
=> ["acccc", "bcccc"]
~~~
Thanks for you guys time.
--
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>