Perhaps there simply should be two different functions, append(char:) and append(unicode:)<br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 14, 2015 at 18:46 Martin Kühl <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 11 December 2015 at 06:52, Chris Lattner via swift-evolution<br>
<<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
>> On Dec 10, 2015, at 11:07 AM, Kevin Ballard via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
>><br>
>> The fact that Swift uses the exact same syntax ("a") for String, Character, and UnicodeScalar can get annoying at times. When unconstrained it's always String, and the only way to disambiguate between the two when used in a context that takes both Character and UnicodeScalar is to explicitly constraint it further, e.g. with `"a" as Character`. A trivial example of this in action is<br>
>><br>
>> var s = ""<br>
>> s.append("c")<br>
>><br>
>> This code looks pretty straightforward, but it throws an ambiguity error (and the annoying part is, it doesn't actually matter which way it's resolved, the behavior is the same).<br>
>><br>
>> Having to type `"c" as Character` and `"c" as UnicodeScalar` can get pretty annoying if you have to do it a lot. It would be great to reduce this typing a bit.<br>
><br>
> In principle you should also be able to say “s.append(Character(“c”))” but I agree that isn’t much better.<br>
<br>
You can also write<br>
<br>
s.append(c("c"))<br>
<br>
as long as you have a `typealias c = Character` in scope, and<br>
typealiases can be block-scoped.<br>
<br>
Of course, whether that helps depends on where and how you encounter<br>
the ambiguity.<br>
<br>
-Martin<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>