Project

General

Profile

Actions

Bug #15984

closed

deleting from a collection while iterating on it

Bug #15984: deleting from a collection while iterating on it

Added by aothelal (Abdelrahman Othman Helal) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:93534]

Description

If you tried to delete from a collection while iterating on it Ruby will allow you to do this flawlessly. This generates a wrong output collection after doing this action. An exception should be thrown to disallow this to be done.

Updated by Hanmac (Hans Mackowiak) over 6 years ago Actions #1 [ruby-core:93536]

that totally depends on how you interate over the collection.

if you do it right, ruby has no problem with that

Updated by shevegen (Robert A. Heiler) over 6 years ago Actions #2 [ruby-core:93537]

I don't think ruby should disallow this via an exception. The use case
seems fairly odd, too - it is often more idiomatic to do .map, .select,
.reject etc...

Updated by alanwu (Alan Wu) over 6 years ago Actions #3 [ruby-core:93538]

This generates a wrong output collection after doing this action.

Could you provide some examples and explain exactly what is wrong with the output collection?

Updated by jeremyevans0 (Jeremy Evans) over 6 years ago Actions #4

  • Status changed from Open to Feedback

Updated by jeremyevans0 (Jeremy Evans) about 6 years ago Actions #5

  • Status changed from Feedback to Closed
Actions

Also available in: PDF Atom