Skip to content

Instantly share code, notes, and snippets.

@azabaj
Created July 29, 2010 13:52
Show Gist options
  • Select an option

  • Save azabaj/498174 to your computer and use it in GitHub Desktop.

Select an option

Save azabaj/498174 to your computer and use it in GitHub Desktop.

Revisions

  1. azabaj renamed this gist Jul 29, 2010. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. azabaj created this gist Jul 29, 2010.
    7 changes: 7 additions & 0 deletions Ruby grep enumerable
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    ["Test", "Foo", "Bar"].grep 'Foo' => ["Foo"]

    ["Test", "Foo", "Bar"].grep /ba/i => ["Bar"]

    >> [nil, 1, "test", 2.5].grep Numeric => [1, 2.5]

    >> [1,5,9,7].grep 5..7 => [5, 7]