[swift-evolution] Add conversion String -> Bool
Mirek Elsner
mirek at elsners.org
Sat Jun 4 13:38:04 CDT 2016
Since the XML and JSON related objects are part of Foundation, I think it would be great to have that functionality in Foundation as well. For “true”, “false”, “1” and “0” (in addition to 1 and 0).
Mirek
> On Jun 4, 2016, at 06:10, Arsen Gasparyan via swift-evolution <swift-evolution at swift.org> wrote:
>
> Hello,
>
> It would be great if we had `init?(_ text: String)` for Bool class. Because sometime when you're processing JSON/XML it can help you a lot.
>
> Examples:
>
> Bool("true") -> true
> Bool("false") -> false
> Bool("TrUE") -> true
> Bool(" true ") -> nil
> Bool("1") -> nil
> Bool("Y") -> nil
> Bool("whatever") -> nil
>
>
> via https://bugs.swift.org/browse/SR-1282 <https://bugs.swift.org/browse/SR-1282>
>
> Thanks.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160604/5b72e032/attachment.html>
More information about the swift-evolution
mailing list