Project

General

Profile

Bug #15984

deleting from a collection while iterating on it

Added by aothelal (Abdelrahman Othman Helal) 5 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
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.

History

Updated by Hanmac (Hans Mackowiak) 5 months ago

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) 5 months ago

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) 5 months ago

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?

#4

Updated by jeremyevans0 (Jeremy Evans) 5 months ago

  • Status changed from Open to Feedback
#5

Updated by jeremyevans0 (Jeremy Evans) 3 months ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF