cog
cog copied to clipboard
Allow variadic arguments
When we have list of a single type (string, integer, etc), we are setting the array as signature. It implies that the function argument needs an array initialisation to make it works, when we could simplify the API changing it for variadic arguments.
Go:
// Signatures
// Before
func Tags(tags []string) {...}
// After
func Tags(tags ...string) {...}
// Usage
// Before
Tags([]string{"tag1", "tag2"})
// After
Tags("tag1", "tag2")
TS:
// Signatures
// Before
tags(tags: string[]) {...}
// After
tags(...tags: string[]) {...}
// Usage
// Before
tags(['tag1', 'tag2'])
// After
tags('tag1', 'tag2')