Ho un pezzo di codice come questo:errore di hash di Ruby: metodo non definito []
my_hash = {}
first_key = 1
second_key = 2
third_key = 3
my_hash[first_key][second_key][third_key] = 100
e l'interprete ruby mi ha dato un errore dice che:
undefined method `[]' for nil:NilClass (NoMethodError)
Quindi cosa significa I non puoi usare hash come quello? o pensi che questo errore potrebbe a causa di qualcos'altro?
Suggerimenti su come eseguire il debug del codice: http://stackoverflow.com/q/3955688/38765 –
Allan, probabilmente dovresti accettare una delle risposte, a meno che tu ritenga che la tua domanda non abbia ricevuto una risposta completa. (Probabilmente o il texasbruce o il mio, dal momento che ti abbiamo detto un modo per ottenere quello che vuoi.Perché ripeto che non è necessariamente un buon stile.) –