Skip to content

Instantly share code, notes, and snippets.

@mjhea0
Created April 23, 2013 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjhea0/5446928 to your computer and use it in GitHub Desktop.
Save mjhea0/5446928 to your computer and use it in GitHub Desktop.
Pull out specific data types from an array via Blocks.
array = [43, "Foo Fighters", 45.7, "not_true", :beans, 8, 42.34]
strings = array.select {|x| x.is_a? String}
symbols = array.select {|x| x.is_a? Symbol}
integers = array.select {|x| x.is_a? Integer}
floats = array.select {|x| x.is_a? Float}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment