[swift-users] Dictionary with optional values
David Sweeris
davesweeris at mac.com
Wed May 18 20:58:00 CDT 2016
This isn't limited to Optional. Any dictionary whose value type conforms to NilLiteralConvertible can be "vulnerable" to some pretty subtle bugs.
- Dave Sweeris
> On May 18, 2016, at 13:16, Jens Alfke via swift-users <swift-users at swift.org> wrote:
>
> (Thinking about it, I can’t see much use for a dictionary of optionals. What’s the difference between “x has no value” and “x has a value of nil”? I guess it’s that when you iterate the keys you see x. This seems like a tricky use that could easily confuse someone reading the code (who could be you, a year later!) Personally I’d prefer a different, clearer solution, unless this was something performance-critical that led to faster code. In which case I’d add lots of comments!)
>
> —Jens
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
More information about the swift-users
mailing list