Something lightweight to discuss: improvement to print(_:separator:terminator:) ?


(Brandon Knope) #1

One thing about print that I find odd to look at is when you don't want to use a line break:

print(someValue, terminator: "")

What if we used an enum for these options, especially for the two most common ones?

enum PrintTerminatorTypes {
    case none
    case lineBreak //default
    case custom(String)
}

print(someValue, terminator: .none)
print(someValue, terminator: .lineBreak)
print(someValue, terminator: .custom(" --- "))

This seems clearer and more self documenting.

Obviously this isn't a really important change but:
1. Swift-Evo seems light lately so why not discuss something...especially something really lightweight
2. It's source breaking (...but it could be offered as an override?)

Brandon

···

Sent from my iPad