. Advertisement .
..3..
. Advertisement .
..4..
I’m getting this error undefined method `[]’ for nil:nilclass when i run the following code:
def extraireAttributs (attributsParam)
classeTrouvee = false
scanTrouve = false
ownerOSTrouve = false
ownerAppTrouve = false
resultat = Hash.new(0)
attributs = Array(attributsParam)
attributs.each do |attribut|
typeAttribut = attribut['objectTypeAttribute']
[...]
NoMethodError: undefined method SOME_METHOD for nil:NilClass
It seems that it crashes when the program executes this line of code:
The class ‘attribut’ is nil and it is not allowed in Ruby. The simplest way to debug is to inspect your array in order to check if one of the items (attributs) in your list is nil or not. You can simply use the following way to inspect:
I hope my suggestions might help.
I think the command line attribute = Array(attributes Param) was causing you problems “undefined method `[]’ for nil:nilclass”
You need to debug, before the loop add command line