@fjfish that's a use case, I've see a lot different ones on a loop as in...
array = 
elements.each do |element|
array =  # instead of array.clear
# more things
Sounds like not using select or find or some of the other enumerable methods
Can also create a lambda and use & to keep it sweet too
Or use &method(:thing) if lambdas don't suit
@esparta also just occurred to me that if you were using tap you'd *have* to use clear
@fjfish yes, must of the time I've see plain arrays initialized and loops with logic, but still, why not using the .clear is not clear to me.
Maybe at some point it had race conditions?
Or maybe people is not aware of .clear exist and making it on C-fashion looks familiar and convenient (as in let the GC do their job at some point).
That's why I'm asking.
A Mastodon instance for Rubyists & friends