考虑 ruby 中的以下代码,假设我从某个地方调用了 prestart:
def tester(process_name, *host_list)
hosts = []
hosts = host_list[0]
hosts[0] = nil
end
def prestart(process_name, *host)
host_list = ['192.168.1.1', '192.168.1.2']
puts host_list.inspect # -> ['192.168.1.1', '192.168.1.2']
tester(process_name, host_list)
puts host_list.inspect # -> [nil, '192.168.1.2']
abort
end
怎么变成零了?这是红宝石的工作原理吗?如果是,我如何确保它不会影响来电者?