<div dir="ltr">I was playing with CharacterSet, and I came up with:<div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">let</span><span style="font-variant-ligatures:no-common-ligatures"> vowels = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">CharacterSet</span><span style="font-variant-ligatures:no-common-ligatures">(charactersIn: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"AEIOU"</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">let</span><span style="font-variant-ligatures:no-common-ligatures"> char: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">Character</span><span style="font-variant-ligatures:no-common-ligatures"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"E"</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">vowels</span><span style="font-variant-ligatures:no-common-ligatures">.contains(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">char</span><span style="font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><br><span style="font-variant-ligatures:no-common-ligatures"></span></p></div><div>That last line doesn't compile: I get "<b style="font-family:menlo;font-size:11px">cannot convert value of type 'Character' to expected argument type 'UnicodeScalar'</b>"</div><div><br></div><div>The problem is, I could not find a simple way to convert from a character to a unicodeScalar. The best I found is the very ugly:</div><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(112,61,170)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">vowels</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(61,29,129)">contains</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures">String</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">char</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">).</span><span style="font-variant-ligatures:no-common-ligatures">unicodeScalars</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">[</span><span style="font-variant-ligatures:no-common-ligatures">String</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">char</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">).</span><span style="font-variant-ligatures:no-common-ligatures">unicodeScalars</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures">startIndex</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">])</span></p></div><div><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"><br></span></div><div>Did I miss anything? Does it have to be that horrific?</div><div><br></div><div>If so, I find using Set much better:</div><div><br></div><div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(112,61,170)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">let</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> vowelsSet: </span><span style="font-variant-ligatures:no-common-ligatures">Set</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"><</span><span style="font-variant-ligatures:no-common-ligatures">Character</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">> = </span><span style="font-variant-ligatures:no-common-ligatures">Set</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">"AEIOU"</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures">characters</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">)</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(79,129,135)"><span style="font-variant-ligatures:no-common-ligatures">vowelsSet</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(61,29,129)">contains</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">(</span><span style="font-variant-ligatures:no-common-ligatures">char</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">)</span></p></div></div><div><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"><br></span></div><div>I must have missed something. Any suggestion welcome</div><div><br></div><div>Jean-Denis</div><div><br></div><div><br></div><div><br></div></div>