This implementation is a bit wrong. printTuple(42)
will output 42<SPACE>
, not 42
.
I'm using this instead;
func print<First, each T>(_ firstValue: First, _ value: repeat each T, separator: String = " ", terminator: String = "\n") {
func printWithPrefix<U>(value: U) {
print(separator, terminator: "")
print(value, terminator: "")
}
print(firstValue, terminator: "")
repeat printWithPrefixSpace(value: each value)
print(terminator, terminator: "")
}
Anyway, print(repeat each value)
will eventually be supported. (Ref)