On Mon, Oct 3, 2016, at 10:52 AM, Harlan Haskins via swift-evolution wrote: > Swift developers frequently use string interpolation as a convenient, > concise syntax for interweaving variable values with strings. The > interpolation machinery, however, has surprising behavior in one > specific case: Optional<T>. If a user puts an optional value into a > string interpolation segment, it will insert either > "Optional("value")" or "nil" in the resulting string. Neither of these > is particularly desirable, so we propose a warning and fix-it to > surface solutions to these potential mistakes.
Is there any way we could instead allow Optionals but just print them the way we print ImplicitlyUnwrappedOptionals? That's almost always how I want my Optionals to work when interpolating. To be specific, this means for .some(x) we just print x, and for .none we print "nil". -Kevin
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution