<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>On Mon, Oct 3, 2016, at 10:52 AM, Harlan Haskins via swift-evolution wrote:<span></span><br></div>
<blockquote type="cite"><div><div><p style="margin-top:0px;margin-bottom:16px;"><span class="highlight" style="background-color:rgba(255, 255, 255, 0)">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: <code style="padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;">Optional<T></code>. If a user puts an optional value into a string interpolation segment, it will insert either <code style="padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;">"Optional("value")"</code> or <code style="padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;">"nil"</code> 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.</span><br></p></div>
</div>
</blockquote><div><br></div>
<div>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".<br></div>
<div><br></div>
<div>-Kevin</div>
</body>
</html>