ruby on rails - Using an array of hashes I need to compare two values -
i have following array of hashes:
[{"dwidnote"=>14, "streetaddress"=>"250 palm valley blvd.", "propertyaddress"=>"250 palm valley blvd."}, {"dwidnote"=>16, "streetaddress"=>"2801 alaskan way", "propertyaddress"=>"2801 alaskan way"}, {"dwidnote"=>17, "streetaddress"=>"300 lakeside drive", "propertyaddress"=>"300 lakeside drive "}, {"dwidnote"=>18, "streetaddress"=>"3817 parkdale", "propertyaddress"=>"3817 parkdale "}]
i need compare values keys streetaddress
, propertyaddress
see if match. values not match need display value key dwidnote
. how do this?
assuming array in variable named a
this:
a.select{|e| e['streetaddress'] != e['propertyaddress']}.map{|e| e['dwidnote']}
will return this:
[17, 18]
Comments
Post a Comment