K
Kelly Dwight Felkins
------=_Part_9367_20485179.1139447912579
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Is there a way for collect to return fewer items than the enumerable the
collect is running on? It looks to me like
map/collect will return at least one value for each item in the array --
I've seen examples of how to return more items, but
not less.
Is there a way to do this more succinctly:
VOWELS =3D %w{a e i o u}
items =3D %w{ a b c d e f g h i}
new_items =3D []
items.each do |item|
new_items << item unless VOWELS.include(item)
end
new_items
map/collect in ruby seems very similar to map in perl except that in perl
the block can return zero or more elements. Is there an method in ruby that
is similar to perl's map?
Thanks,
-Kelly
------=_Part_9367_20485179.1139447912579--
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Is there a way for collect to return fewer items than the enumerable the
collect is running on? It looks to me like
map/collect will return at least one value for each item in the array --
I've seen examples of how to return more items, but
not less.
Is there a way to do this more succinctly:
VOWELS =3D %w{a e i o u}
items =3D %w{ a b c d e f g h i}
new_items =3D []
items.each do |item|
new_items << item unless VOWELS.include(item)
end
new_items
map/collect in ruby seems very similar to map in perl except that in perl
the block can return zero or more elements. Is there an method in ruby that
is similar to perl's map?
Thanks,
-Kelly
------=_Part_9367_20485179.1139447912579--