Overview
I have a function f1
that I would like to use with Array
and Set
I have declared the function parameter as any Sequence<Int>
Questions
- For function parameters, is there any difference between
any
orsome
? - Is one preferred over the other? Why?
Code
let array = [1, 2, 3, 4, 5, 6, 7]
let set = Set([1, 2, 3, 4, 5, 6, 7])
//When a parameter is declared as `any` or `some` - Is there any difference?
func f1(sequence: any Sequence<Int>) {
sequence.forEach { print($0) }
}
f1(sequence: array)
f1(sequence: set)