Simple and satisfying rewriting: casting
names.append(name: "whatever", important: importantSwitch.on as Bool)
Even better, if you do not want to perform any casting or assignment dance, use extendinstead append:
names.extend([(name: "whatever", important: importantSwitch.on)])
Martin R, , :
typealias Pair = (name:String, important:Bool)
var names = [Pair]()
names.append(Pair(name: "whatever", important: importantSwitch.on))
, , extend , append , : . , , - , , , .
, names.append(...), - append, name: important: - , ? , , . , , ; , , ( ). extend , . .
source
share