Select certain types from Array
If you have an array of values in Ruby and select items of a certain type it easily possible.
h = [1, 2, 3, {t: 3}]
h.grep(Hash) # [{t: 3}]
Written by Dinesh Vasudevan
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#