ruby - Remove element from array by type -
i have following array:
["--",1,2,3,4]
how can remove elements array element type, ie. remove non-integer values array?
i'd :-
ary = ["--",1,2,3,4] ary = ary.grep(integer) ary # => [1, 2, 3, 4]
note :- if don't want mutate original array use new_ary
instead of ary
. like
new_ary = ary.grep(integer)
Comments
Post a Comment