我一直在試圖寫在Ruby中while循環類似於以下:未定義的方法 '+ @' - 紅寶石錯誤
number = 3
string = "lalaLand"
def main(number, string)
n = 1
while n <= number do
print string + 'something else' + n.to_s
n = n + 1
end
end
main(number, string)
而且我不斷收到錯誤:
...: undefined method `[email protected]' for "lalaLand":String (NoMethodError)
燦任何人都可以幫助我? 感謝
----編輯---(實際的代碼,也許有一些像我錯過)
devel_number
被聲明爲INT唯一一個(即:devel_number = 4
,其餘都是字符串:project_name = "lalaLand"
) ...
def b_sani_dev(project_home, source_dir, project_name, devel_number)
n = 1
while n <= devel_number do
system 'mkdir -p ' + project_home + 'dev_'+ n.to_s + '/main'
system 'mkdir -p ' + project_home + 'dev_' + n.to_s + '/LOG'
n = n + 1
end
b_sani_dev(project_home, source_dir, project_name, devel_number)
對我來說運行良好。 – User1578
DEF b_sani_dev(PROJECT_HOME,source_dir,PROJECT_NAME,devel_number) n = 1的 而N <= devel_number做 系統 '的mkdir -p' + PROJECT_HOME + 'dev的+' + n.to_s + '/ M' 系統「的mkdir - p'+ project_home +'dev_'+ n.to_s +'/ L' n = n + 1 end – mhz
hmm我的不好,將添加編輯真實代碼 – mhz