module Nuggets::Array::FlushMixin

Public Instance Methods

flush → anArray click to toggle source
flush { |array| ... } → anObject

If a block is given, yields array to the block and clears it afterwards; returns the return value of the block. Otherwise clears array and returns its contents.

# File lib/nuggets/array/flush_mixin.rb, line 38
def flush
  ret = block_given? ? yield(self) : dup
  clear
  ret
end