Project

General

Profile

Actions

Bug #10722

closed

Array#keep_if is borked if user calls 'break'

Added by wanabe (_ wanabe) almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-01-09 trunk 49192) [x86_64-darwin14]
[ruby-dev:48805]

Description

ref. [Bug #2545]

$ ruby -e 'a = [5,6,7,8,9,10]; a.keep_if { |x| break if x > 8; x >= 7 }; p a'
[7, 8, 7, 8, 9, 10]
$ ruby -e 'a = [5,6,7,8,9,10]; a.delete_if { |x| break if x > 8; x < 7 }; p a'
[7, 8, 9, 10]

I was expecting the above scripts to be same results.


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #2545: Array#delete_if is borked if user calls 'break'Closedmatz (Yukihiro Matsumoto)01/02/2010Actions
Related to Ruby master - Feature #10714: Array#reject! nonlinear performance problemClosedakr (Akira Tanaka)01/08/2015Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0