Name this python/ruby language construct (using array values to satisfy function parameters)

前端 未结 7 1644
予麋鹿
予麋鹿 2020-12-14 02:37

What is this language construct called?

In Python I can say:

def a(b,c): return b+c
a(*[4,5])

and get 9. Likewise in Ruby:

7条回答
  •  一整个雨季
    2020-12-14 03:05

    The majority of the questions have already been answered, but as to the question "What is the name of the * operator?": the technical term is "asterisk" (comes from the Latin word asteriscum, meaning "little star", which, in turn, comes from the Greek ἀστερίσκος). Often, though, it will be referred to as "star" or, as stated above, "splat".

提交回复
热议问题