Forum: Ruby-dev [ruby-trunk - Bug #10722] Array#keep_if is borked if user calls 'break'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1a89a8ff89c39148448a228115925b29?d=identicon&s=25 unknown (Guest)
on 2015-01-09 09:53
(Received via mailing list)
Issue #10722 has been updated by _ wanabe.

Related to Bug #2545: Array#delete_if is borked if user calls 'break'
added

----------------------------------------
Bug #10722: Array#keep_if is borked if user calls 'break'
https://bugs.ruby-lang.org/issues/10722#change-50880

* Author: _ wanabe
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.3.0dev (2015-01-09 trunk 49192) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
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.
This topic is locked and can not be replied to.