join用于将数组转换为字符串。下面,*names
被加入,被输出。这是否意味着参数是数组?
def introduction( age, gender, *names)
"Meet #{names.join(" ")}, who's #{age} and #{gender}"
end
puts introduction(28, "Male", "Sidu", "Ponnappa", "Chonira")
这输出:
认识 28 岁的男性 Sidu Ponnappa Chonira