Hi, Well, it's really telling you that something that you're indexing into is nil. Not sure which of the things in that big assignment is the nil one, but something there is. HTH, Carey -----Original Message----- From: mati829 / gmail.com [mailto:mati829 / gmail.com] Sent: Monday, November 03, 2008 2:17 PM To: ruby-talk ML Subject: Undefined method '[]' I dont know why. Hello , I have problem with my script. /////////////this function return true or false def moznazbudowac?(co,sesja,stan) budynek = "" catch(:redo) do case co when 1 budynek = "Kopalnia metalu" when 2 budynek = "Kopalnia krysztalu" when 3 budynek = "Kopalnia deuteru" end end poziom = stan[budynek] # 11 poziom = poziom.to_i surowce_pods = bazadanych(co) #output [60,15,0,1.5] surowce_potrz = [0,0,0,0] surowce_potrz[0] = surowce_pods[0].to_i *surowce_pods[3].to_i**(poziom-1)#Error [.....]# further part of script ////////////////////// Error : Undefined method '[]' for nil:NilClass <NoMethodError> I try to modify script but dont know how fix this error. a = moznazbudowac?(1,sesja,stan) // this is working But when i execute this sesja = sesja() stan = skaner () kolejka() return array i was testing with array [1] test_kolejki = kolejka() kolejkowanie(test_kolejki,sesja,stan)#error I have error in function kolejkowanie() and i line above and in function moznazbudowac?. ///////////////// def kolejkowanie(kolejka,sesja,stan) dlugosc = kolejka.length dlugosc -=1 nr = 0 while nr<=dlugosc zbudowano = 0 while zbudowano == 0 if moznazbudowac?(kolejka[nr],sesja,stan) == true then#error zbuduj(kolejka[nr],sesja) kolejka.pop nr +=1 zbudowano = 1 else "Nie starczy surowcow" end end end end /////////////////// -- Posted via http://www.ruby-forum.com/.