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
Closed

Array#delete_if - no size update #1877

regfaker opened this issue Aug 1, 2014 · 4 comments
Milestone

Comments

@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]

@lucasallan
Copy link
Member

@regfaker Thanks. I'll take a look.

@dmarcotte
Copy link
Contributor

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.

@lucasallan
Copy link
Member

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

@rtyler
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 as completed 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants