def get_name(id)
c=['a','b','c']
return c[id]
end
def get_str()
a=['abcd','bcde','cdef']
a.each do |str|
puts "#{get_name(id)} to #{str}"
end
end
get_str()
请问我怎么实现
a to abcd
b to bcde
c to cdef
['a','b','c'].zip(['abcd','bcde','cdef']) .each do |x,y| "#{x} to #{y} " end
def get_str(*args)
args.each do |arg|
arg_str = []
4.times { arg_str << arg; arg = arg.next}
puts arg_str.first + " to " + arg_str.join
end
end
get_str('a', 'b', 'c', 'd')
楼主是要这样重写么?XD
new.each_with_index do |name,index|
system "mv "+get_old_name(index).to_s+" "+name.to_s
end
可以这样吗?