[swift-users] Why there's no Character literals?

Saagar Jha saagarjha28 at gmail.com
Sun Jul 10 23:56:37 CDT 2016


Yes, but then a similar complaint could be made that I wanted a String this time. The only real way to tell the difference is to use something like single quotes.

> On Jul 10, 2016, at 14:03, Rick Mann via swift-users <swift-users at swift.org> wrote:
> 
> 
>> On Jul 10, 2016, at 11:44 , Saagar Jha via swift-users <swift-users at swift.org> wrote:
>> 
>> Well, what if you wanted to create a String with one character? There’s no way to differentiate.
> 
> That hardly seems like the justification. In that case, you'd specify the type:
> 
>    let s: String = '\n'
> 
> 
>> 
>>> On Jul 7, 2016, at 02:35, 王 黎明 via swift-users [swift-users at swift.org](mailto:swift-users at swift.org) wrote: >
>> 
>> In Swift, we must specify the type for Character variables(because there’s no Character literals):
>> 
>> let eol: Character = “\n”
>> 
>> it's not a big problem, but, Is it the unique case that can’t use type infer?
>> 
>> swift-users mailing list swift-users at swift.org https://lists.swift.org/mailman/listinfo/swift-users
>> 
>> -- 
>> -Saagar Jha
>> _______________________________________________
>> swift-users mailing list
>> swift-users at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
> 
> 
> -- 
> Rick Mann
> rmann at latencyzero.com
> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160710/e5d1766f/attachment.html>


More information about the swift-users mailing list