3 ms·
I would implement that like: zip(names, 1...names.count).forEach { name, index in print("Person \(index) is called \(name)") } Or, in an ideal
by cballard 11y ago
I would implement that like:
zip(names, 1...names.count).forEach { name, index in
print("Person \(index) is called \(name)")
}
Or, in an ideal world:
zip(names, 1...names.count)
.map({ name, index in "Person \(index) is called \(name)" })
.forEach(print)
Currently, that isn't valid Swift, "print" can't be used like that, though if you define a closure it works:
let printIt = { x in print(x) }
zip(names, 1...names.count)
.map({ name, index in "Person \(index) is called \(name)" })
.forEach(printIt)
I think that Swift could use = for equality, since assignments return Void and comparison returns Bool. Maybe it should.
But your argument boils down to "if you can't be clear everywhere, don't be clear anywhere". That's not a good goal.
- dstanko 11y agoMy argument ultimately "there are better things to do". At the same time, interpreting ++ as add-add is certainly not an argument. You can say that you don't like infix and postfix operators, but not whether they are readable. If you consider readability, then why !a instead of not(a)? Why || instead of or?