I am trying to loop on an Array of Hashes. When I reach the point where I fetch the Enumerator to start looping, I get the following error:
undefined method `[]' for nil:NilClass
My code looks like the following:
def extraireAttributs (attributsParam)
classeTrouvee = false
scanTrouve = false
ownerOSTrouve = false
ownerAppTrouve = false
resultat = Hash.new(0)
attributs = Array(attributsParam)
attributs.each do |attribut| #CRASHES HERE!!!
typeAttribut = attribut['objectTypeAttribute']
[...]
I checked in debug mode to make sure the attributsParams
argument and the attributs
variable are not nil or empty. Both (because they are the same!) contain 59 Hashes objects, but I still cannot get an Enumerator on the Array.
Why do I keep on getting this error?
Thanks!
attributsParam
look like? If there are too many hashes, just show 3 of them! – Conto