Yes.. possible using Object#tap
and Array#shift
.
a = ["r", "u", "b", "y"]
p a.tap{|i| i.shift(2)}
# >> ["b", "y"]
p a
# >> ["b", "y"]
If you want to monkey-patch the class Array.
class Array
def mystery_function!(n)
shift(n);self
end
end
a = ["r", "u", "b", "y"]
p a.mystery_function!(2)
# >> ["b", "y"]
p a
# >> ["b", "y"]