Actions
Bug #12178
closedEnumerable#inject(:+) doesn't respect redefined Fixnum#+
Description
r54120以降、Fixnum#+ を再定義している場合(する奴はいないとは思うものの)、inject(:+) の中で再定義後のメソッドが呼ばれなくなります。
C:\> ruby -ve "class Fixnum; def +(o); self*o; end; end; p [1,3,5].inject(:+)"
ruby 2.4.0dev (2016-03-15 trunk 54118) [x64-mswin64_100]
-e:1: warning: method redefined; discarding old +
15
C:\> ruby -ve "class Fixnum; def +(o); self*o; end; end; p [1,3,5].inject(:+)"
ruby 2.4.0dev (2016-03-15 trunk 54120) [x64-mswin64_100]
-e:1: warning: method redefined; discarding old +
9
C:\> ruby -ve "class Fixnum; def +(o); self*o; end; end; p [1,3,5].inject(&:+)"
ruby 2.4.0dev (2016-03-15 trunk 54120) [x64-mswin64_100]
-e:1: warning: method redefined; discarding old +
15
Updated by usa (Usaku NAKAMURA) over 8 years ago
- Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONTNEED
Actions
Like0
Like0Like0