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

前端 未结 7 1641
予麋鹿
予麋鹿 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:09

    I've been calling it "list expansion", but I don't think that's standard terminology (I don't think there's any...). Lisp in all versions (Scheme included), and Haskell and other functional languages, can do it easily enough, but I don't think it's easy to do in "mainstream" languages (maybe you can pull it off as a "reflection" stunt in some!-).

    0 讨论(0)
提交回复
热议问题