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
38 def flush
39   ret = block_given? ? yield(self) : dup
40   clear
41   ret
42 end