You are viewing a single comment's thread. Return to all comments →
def func_any(hash) hash.any? {|key, value| key.is_a?(Integer)} end
def func_all(hash) hash.all? {|key, value| value.is_a?(Integer) && value < 10} end
def func_none(hash) hash.none? {|key, value| value.nil?} end
def func_find(hash) hash.find do |key, value| (key.is_a?(Integer) && value.is_a?(Integer) && value < 20) || (key.is_a?(String) && value.is_a?(String) && value.start_with?('a')) end end
Seems like cookies are disabled on this browser, please enable them to open this website
Ruby Enumerables: 'any', 'all', 'none', and 'find'
You are viewing a single comment's thread. Return to all comments →
Check this one
def func_any(hash) hash.any? {|key, value| key.is_a?(Integer)} end
def func_all(hash) hash.all? {|key, value| value.is_a?(Integer) && value < 10} end
def func_none(hash) hash.none? {|key, value| value.nil?} end
def func_find(hash) hash.find do |key, value| (key.is_a?(Integer) && value.is_a?(Integer) && value < 20) || (key.is_a?(String) && value.is_a?(String) && value.start_with?('a')) end end