<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Apologize for the late response, this message got buried in my inbox.<div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Saagar Jha</div>

</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Apr 23, 2017, at 23:23, Rick Mann &lt;<a href="mailto:rmann@latencyzero.com" class="">rmann@latencyzero.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On Apr 22, 2017, at 12:23 , Saagar Jha &lt;<a href="mailto:saagar@saagarjha.com" class="">saagar@saagarjha.com</a>&gt; wrote:<br class=""><br class=""><br class="">Saagar Jha<br class=""><br class=""><blockquote type="cite" class="">On Apr 21, 2017, at 04:35, Rick Mann via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class="">I have a debugLog() method that looks like this:<br class=""><br class="">func<br class="">debugLog&lt;T&gt;(_ inMsg: T, _ inFile : String = #file, _ inLine : Int = #line)<br class=""></blockquote><br class="">Well, for starters, I don’t see why you need to make this function generic. Why not make inMsg an `Any?`?<br class=""></blockquote><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">So I can write debugLog(&lt;something other than string&gt;)</span><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>Have you tried using `Any?`? You can pass in other stuff…</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class="">{<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let df = DateFormatter()<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>df.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let time = df.string(from: Date())<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let file = (inFile as NSString).lastPathComponent<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>print("\(time) \(file):\(inLine) &nbsp;&nbsp;&nbsp;\(inMsg)”)<br class=""></blockquote><br class="">Try \(inMsg ?? “nil”).<br class=""></blockquote><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">No, this is missing the point. I don't want to have to write this everywhere. I just want to tell the compiler not to issue the warning in these cases, much in the way you can tell the compiler to check printf format specifiers.</span><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>The fundamental issue here is that printing an Optional is probably not what you want to do, since it will print Optional(“your wrapped value”). If this is what you want, you will need to be explicit with String(describing:); if not, then use the nil coalescing operator to fallback to a value you want. You can also try guaranteeing that the value is not an optional by unwrapping it.</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class="">}<br class=""><br class="">Is there any way to decorate it so that string interpolation of optionals passed to it inMsg don't produce the warning about using debugDescription? In the case of debug logging, that's completely acceptable, and I don't want to have to write String(describing:) everywhere.<br class=""><br class=""><br class="">--<span class="Apple-converted-space">&nbsp;</span><br class="">Rick Mann<br class=""><a href="mailto:rmann@latencyzero.com" class="">rmann@latencyzero.com</a><br class=""><br class=""><br class="">_______________________________________________<br class="">swift-users mailing list<br class="">swift-users@swift.org<br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></blockquote><br class=""></blockquote><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">--<span class="Apple-converted-space">&nbsp;</span></span><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Rick Mann</span><br style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:rmann@latencyzero.com" style="font-family: SFUIText-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">rmann@latencyzero.com</a></div></blockquote></div><br class=""></div></body></html>