Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.21 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. collection = [1, 'a', 2, 'b', 'c']
  2.  
  3. def  collection.filter &block
  4.   result = []
  5.   self.each do |t|
  6.     result << t if block.call t
  7.     result
  8.   end
  9. end
  10.  
  11. puts collection.filter { |x| x.is_a?(String) }