G
Gavin Kistner
I occasionally find myself with gsub regexp that either eat too much,
or work within a nesting, such that I need to run gsub more than once
in order to get the desired end result. The code I end up writing
tends to be of the form:
while foo.gsub!( /.../, ... ); end
Frankly, I really don't like that. It's like JS people who write
things like:
for ( var walkerNode = this; walkerNode.parent; walkerNode =
walkerNode.parent ){}
'abusing' the for loop construct to hold their logic.
Is there some other form in Ruby of "keep doing this until it returns
nil" that is less...gross?
or work within a nesting, such that I need to run gsub more than once
in order to get the desired end result. The code I end up writing
tends to be of the form:
while foo.gsub!( /.../, ... ); end
Frankly, I really don't like that. It's like JS people who write
things like:
for ( var walkerNode = this; walkerNode.parent; walkerNode =
walkerNode.parent ){}
'abusing' the for loop construct to hold their logic.
Is there some other form in Ruby of "keep doing this until it returns
nil" that is less...gross?