Reputation: 14975
My class declares an array
var laps: (start: NSDate!, end: NSDate!)[] = []
When a tuple is added to this array I'd like to be able to do something like
let now = NSDate()
var lap = (now, nil)
laps.append(lap)
But at the append
I get the error Missing argument for parameter 'end' in call
.
Upvotes: 2
Views: 1350
Reputation: 24041
I've tried to following, and it looked correct syntactically:
typealias MyTuple = (start: NSDate!, end: NSDate?)
then in the method, I did:
var laps: Array<MyTuple> = Array()
laps.append((NSDate.date(), nil))
Upvotes: 7
Reputation: 93276
There's a bug in using .append
with arrays of tuples. You can use the +=
operator instead:
laps += lap
Upvotes: 5