柔軟に受け取るようにできているっぽい
class A
def initialize(arg1, arg2, a:, b:, c:)
@arg1 = arg1
@arg2 = arg2
@keyword_arg_a = a
@keyword_arg_b = b
@keyword_arg_c = c
end
def echo
p @arg1
p @arg2
p @keyword_arg_a
p @keyword_arg_b
p @keyword_arg_c
end
end
A.new(:some, :how, a: 1, b: 2, c: 3).echo
options = { a: 1, b: 2, c: 3 }
A.new(:some, :how, **options).echo
A.new(:some, :how, options).echo
# :some
# :how
# 1
# 2
# 3
Original by Github issue
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。