Skip to content
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

Array#delete_if - no size update #1877

Closed
regfaker opened this Issue Aug 1, 2014 · 4 comments

Comments

Projects
None yet
5 participants
@regfaker
Copy link

regfaker commented Aug 1, 2014

jruby-1.7.6 [ x86_64 ](using rvm)

a=[1,2,3,4]
a.delete_if { |e| puts a.size; e % 2 == 0 }

4
4
4
4
=> [1, 3]

End result ok - array elements were deleted, but size was not updated during delete_if iterations and it should be.
If I run this in ruby-1.9.3-p484 [ x86_64 ]:
4
4
3
3
=> [1, 3]

@sh286

This comment has been minimized.

Copy link
Member

sh286 commented Aug 3, 2014

@regfaker Thanks. I'll take a look.

@dmarcotte

This comment has been minimized.

Copy link
Contributor

dmarcotte commented Aug 3, 2014

Hey @lucasallan, I've got a fix together for this (going to send it soon, just want to validate on Travis first)

Apologies if we've duplicated work... I just saw your note now.

@sh286

This comment has been minimized.

Copy link
Member

sh286 commented Aug 3, 2014

@dmarcotte No problem at all. Thank you for let me know.

@rtyler

This comment has been minimized.

Copy link

rtyler commented Aug 7, 2015

This is behaving properly as of JRuby 9k

[11] pry(main)> JRUBY_VERSION
=> "9.0.0.0"
[12] pry(main)> a=[1,2,3,4]
=> [1, 2, 3, 4]
[13] pry(main)> a.delete_if { |e| puts a.size; e % 2 == 0 }
4
4
3
3
=> [1, 3]
[14] pry(main)> 

@rtyler rtyler closed this Aug 7, 2015

@enebo enebo added this to the JRuby 9.0.1.0 milestone Aug 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.