No, Ruby has nothing of the kind. Only certain "compound statements" are allowed by Ruby syntax, and this statement is not one of them.
However, under certain circumstances there may be workarounds (but not this one). If, say, you had an array, then instead
ary = ary.select { ... } if foo
ary = ary.select { ... } if bar
ary = ary.compact
you could do
ary.select! { ... } if foo
ary.select! { ... } if bar
ary.compact!
(This can have unintended consequences, yes, because an internal mutation is generally dangerous, but in some cases it is desirable. Do not do this to shorten your code.)
source
share