Go Unpacking Array As Arguments

前端 未结 4 1997
南旧
南旧 2021-01-30 01:13

So in Python and Ruby there is the splat operator (*) for unpacking an array as arguments. In Javascript there is the .apply() function. Is there a way of unpacking an array/sli

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 02:04

    No, there's no direct support for this in the language. Python and Ruby, as well as Javascript you're mentioning; are all dynamic/scripting languages. Go is way closer to, for example, C than to any dynamic language. The 'apply' functionality is handy for dynamic languages, but of little use for static languages like C or Go,

提交回复
热议问题