I don’t see what there is to be confused about. A “literal” is literally a bunch of characters in source code. The compiler interprets those characters as representing whatever type is appropriate to the context.
For the case at hand, a boolean literal can be interpreted as any type which conforms to the ExpressibleByBooleanLiteral protocol. If the context provides no information, the compiler defaults to interpreting a boolean literal as representing a Bool. The situation is similar for every other kind of literal. For example, “2” defaults to being interpreted as an Int, but if the context requires a Double then it will be interpreted as a Double. The text “2” does not have a type of its own. Nevin On Mon, Nov 21, 2016 at 3:55 PM, Rick Mann via swift-users < swift-users@swift.org> wrote: > > > On Nov 21, 2016, at 09:46 , Kenny Leung via swift-users < > swift-users@swift.org> wrote: > > > > This is so confusing. "Literals are untyped", but there’s a > “BooleanLiteral”, which is obviously of type Boolean. > > Agreed. > > -- > Rick Mann > rm...@latencyzero.com > > > _______________________________________________ > swift-users mailing list > swift-users@swift.org > https://lists.swift.org/mailman/listinfo/swift-users >
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users