Module: Nuggets::Array::FlushMixin
- Included in:
- Array
- Defined in:
- lib/nuggets/array/flush_mixin.rb
Instance Method Summary collapse
-
#flush ⇒ Object
call-seq: array.flush => anArray array.flush { |array| … } => anObject.
Instance Method Details
#flush ⇒ Object
call-seq:
array.flush => anArray
array.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.
38 39 40 41 42 |
# File 'lib/nuggets/array/flush_mixin.rb', line 38 def flush ret = block_given? ? yield(self) : dup clear ret end |