i trying count number of matching appid in 2 separate hashes, solution feels clunky. can suggest 'ruby' way of doing this?
#hash array: {"appid"=>240, "playtime_forever"=>103} {"appid"=>2670, "playtime_forever"=>1099} #this steam data interested def games_in_common(friend_hash,other_hash) arr1=array.new arr2=array.new other_hash.keys.each{|k| arr1<<other_hash[k] } friend_hash.keys.each{|k| arr2<<friend_hash[k] } return arr1 & arr2 end
this return values common in both hashes
def games_in_common(friend_hash,other_hash) other_hash.values & friend_hash.values end
Comments
Post a Comment