> On Apr 22, 2017, at 12:23 , Saagar Jha <[email protected]> wrote:
>
>
> Saagar Jha
>
>> On Apr 21, 2017, at 04:35, Rick Mann via swift-users <[email protected]>
>> wrote:
>>
>> I have a debugLog() method that looks like this:
>>
>> func
>> debugLog<T>(_ inMsg: T, _ inFile : String = #file, _ inLine : Int = #line)
>
> Well, for starters, I don’t see why you need to make this function generic.
> Why not make inMsg an `Any?`?
So I can write debugLog(<something other than string>)
>
>> {
>> let df = DateFormatter()
>> df.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
>> let time = df.string(from: Date())
>>
>> let file = (inFile as NSString).lastPathComponent
>> print("\(time) \(file):\(inLine) \(inMsg)”)
>
> Try \(inMsg ?? “nil”).
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.
>
>> }
>>
>> 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.
>>
>>
>> --
>> Rick Mann
>> [email protected]
>>
>>
>> _______________________________________________
>> swift-users mailing list
>> [email protected]
>> https://lists.swift.org/mailman/listinfo/swift-users
>
--
Rick Mann
[email protected]
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users