-
-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add specs for Array#reject!, delete_if 2.3 change #273
Conversation
|
||
ruby_version_is "2.3" do | ||
it "updates the receiver after all blocks" do | ||
@object.send(@method) do |i| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick: could you update the block variable to be e
?
i
sounds like index but here it's an element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, 👍
Thanks a lot, looks good! |
From ruby#175: Array#select!, Array#keep_if, Array#reject!, and Array#delete_if no longer changes the receiver array instantly every time the block is called. Feature #10714 Note, select! and keep_if's behavior seems to be unchanged with 2.3. I tested with 2.3.1, 2.2.5, 2.1.8, and 2.0.0-p648 and they don't mutate the receiver after each block, only after all blocks.
f0ed330
to
e68a19a
Compare
@eregon Updated. I didn't want to change unrelated block variables to |
The changes while iterating in [1] pry(main)> a = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
[2] pry(main)> a.keep_if { |e| p a; e.even? }
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
[2, 2, 3, 4, 5]
[2, 2, 3, 4, 5]
[2, 4, 3, 4, 5]
=> [2, 4]
[3] pry(main)> RUBY_VERSION
=> "2.2.3" You are right though it seems there is not much difference between latest 2.2 and 2.3. |
Thank you for your contribution, it's much appreciated! If you feel on a roll, you can try spec'ing
Yes absolutely, I meant only those in your changes. |
From #175:
Array#select!, Array#keep_if, Array#reject!, and Array#delete_if
no longer changes the receiver array instantly every time the
block is called. Feature #10714
Note, select! and keep_if's behavior seems to be unchanged with 2.3.
I tested with 2.3.1, 2.2.5, 2.1.8, and 2.0.0-p648 and they don't mutate the
receiver after each block, only after all blocks.