当我尝试更改数组项时,我收到关于没有 + 方法的错误?请帮忙。
nameChar = [ '_','a','b','c','d','e','f','g','h','i','j','k','l','m','n',
'o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9' ]
name = File.open('read.txt', &:readline)
rname = name.split('')
ref = []
newRef = []
bump = 0
rname.each do |let|
ref << nameChar.index(let)
end
puts ref
ref[0] += 1
ref.each do |numb|
numb = numb + bump
if numb > 36
bump = 1
numb = 0
else
bump = 0
end
newRef << numb
end
错误消息是:new.rb:13:in 'block in': undefined method `+' for nil:NilClass (NoMethodError)