【Ruby】splat演算子
メソッドに渡される引数の数を事前に決めておきたくない場合に使う。可変長引数を取れるようにする。
def do_sth(*input) input.each {|x| puts x } end do_sth(3,4,5) # => 3 # => 4 # => 5
double splat演算子:キーバリューを引数にとる
def do_sth(**input) input.each {|k,v| puts v } end do_sth(a:3, b:4, c:5) # => 3 # => 4 # => 5