Closed pokryfka closed 4 years ago
@pokryfka First off, thank you for your PR. I appreciate your interest to contribute to this project!
Could you explain your specific use case for this feature? Without a custom string interpolation type (i.e. bare ExpressibleByStringInterpolation
), I'm not sure I understand what this gives you that ExpressibleByStringLiteral
doesn't.
example:
let durationInSeconds: Float = 1
var metadata = [String: AnyEncodable]()
// works
metadata["duration1"] = AnyEncodable("\(durationInSeconds)s")
// error: Cannot assign value of type 'String' to subscript of type 'AnyEncodable'
metadata["duration2"] = "\(durationInSeconds)s"
solved by
extension AnyEncodable: ExpressibleByStringInterpolation {}
this is a very common use case for me, there may be a different solution to that
@pokryfka Oh, huh. I don't think I was fully aware of this behavior, so thanks for spelling that out for me. I'll work on getting the tests to pass reliably on Linux and get this merged soon.
According to NASA's Jet Propulsion Laboratory 15 decimal places of π is sufficient for any physical calculation. Rather than work or explain around the inherently thorny issues of floating-point precision and JSON serialization, let's just use 15 places throughout and call it a day.
Thanks again for your help with this, @pokryfka. Your changes are now live in version 0.3.0.
@mattt please let me know if you think it makes sense to update/cleanup this PR and if so, how
I think
ExpressibleByStringInterpolation
is very useful, I typically add metadata that wayhaving said that its a one-liner to add in a project, and the challenge seems to be making the tests nice and work properly on different versions/platforms ;-)