Swift Tip - Using variadic parameters

Want your array parameters to look way cooler?

Boring

1
2
3
4
5
func trapInUpsideDown(people: [String]) {
// ... your code here
}
trapInUpsideDown(people: [“Dustin”,”Mike”,”Lucas”, "Will"])

Cooler look

1
2
3
4
5
func trapInUpsideDown(_ people: String...) {
// ... your code here
}
trapInUpsideDown(“Dustin”,”Mike”,”Lucas”, "Will")

😉

Partager Commentaires