<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=""><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 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:</div><br class="Apple-interchange-newline"><div class=""><div 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=""></div></div></blockquote><div><br class=""></div><div>Well, for starters, I don’t see why you need to make this function generic. Why not make inMsg an `Any?`?</div><br class=""><blockquote type="cite" class=""><div class=""><div 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=""></div></div></blockquote><div><br class=""></div><div>Try \(inMsg ?? “nil”).</div><br class=""><blockquote type="cite" class=""><div class=""><div 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="">-- <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=""></div></div></blockquote></div><br class=""></body></html>