Skip to content

Instantly share code, notes, and snippets.

Created August 18, 2015 21:57
Show Gist options
  • Save anonymous/e02ba24385664eb6e340 to your computer and use it in GitHub Desktop.
Save anonymous/e02ba24385664eb6e340 to your computer and use it in GitHub Desktop.
Problem: Need to see if string element ["GroupName"] within array "myarr" indexes exists within cp["notes"]
myarr = [{"GroupName"=>"MyFirstGroup", "Id"=>114}, {"GroupName"=>"Interest - Email", "Id"=>101}, {"GroupName"=>"New Customer", "Id"=>102}, {"GroupName"=>"New Lead", "Id"=>135}]
cp["notes"] = "Hello. This is fun. MyFirstGroup is fun."
Normally, I would do:
myarr.each do |arr|
puts "Yup, it's here" if cp["notes"].include? arr["GroupName"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment