i need to pull out some specific values from a nested hash, but nils
are driving me crazy. in the following example, if address_details,
country, administrative_area, locality OR postal_code are nil i get
"The error occurred while evaluating nil.[]"

zip = placemark['address_details']['country']['administrative_area']
['locality']['postal_code']['postal_code_number']

i tried

unless placemark['address_details']['country']['administrative_area']
['locality']['postal_code']['postal_code_number'].nil?

but if anything above postal_code_number is nil i still get the error.
i could check each level but that is really ugly.

is there a easy way to check if postal_code_number exists?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to