ruby - Resolv an error -


a = [1,0,1] b = [101101, 0101100, 1011001101, 11000111, 1010110] = 0 j = 0 c = [] x = 0 d = []  while x < 5   c.push b[i].to_s.split('')   p c   x = x +1 end  while < 5   e = c[i].length   e = e + 1   while j < e     d[i][j] = a[i][j % 3] ^ b[i][j]     puts d     j = j + 1   end   = + 1 end   ==> resolv error line : d[i][j] = a[i][j % 3] ^ b[i][j] ====>  __.rb:18: undefined method `[]=' nil:nilclass (nomethoderror) 

i not see ..

thanks

if want use d[i][j] should create 2 dimension:

... d[i] = [] while j < e   d[i][j] = a[i][j % 3] ^ b[i][j]   puts d   j = j + 1 end ... 

but it's strange code anyway. why using a[i][j % 3] if a one-dimensional array?


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -