title: Initialize a String from a range of Characters in Swift
body: <p>In our code, we found a bug from not writing the alphabet correctly. Instead of <code>&quot;0123456789abcdefghijklmnopqrstuvwxyz&quot;</code>, we had <code>&quot;0123456789abcdefghijklmnoqprstuvwxyz&quot;</code>. So we are wondering if it's possible to avoid similar typo by declaring Strings made from ranges of characters?</p>
  <p>Using Swift 4.1+, we tried:</p>
  <h3>attempt 1</h3>
  <pre><code>let 1: String = &quot;0&quot;...&quot;9&quot; + &quot;a&quot;...&quot;z&quot;
  </code></pre>
  <blockquote>
  <p>Adjacent operators are in non-associative precedence group 'RangeFormationPrecedence'</p>
  </blockquote>
  <h3>attempt 2</h3>
  <pre><code>let 2: String = (&quot;0&quot;...&quot;9&quot;) + (&quot;a&quot;...&quot;z&quot;)
  </code></pre>
  <blockquote>
  <p>Binary operator '+' cannot be applied to two '<code>ClosedRange&lt;String&gt;</code>' operands</p>
  </blockquote>
  <h3>attempt 3</h3>
  <pre><code>let 3: String = String(&quot;0&quot;...&quot;9&quot;) + String(&quot;a&quot;...&quot;z&quot;)
  </code></pre>
  <blockquote>
  <p>Cannot invoke initializer for type 'String' with an argument list of type '<code>(ClosedRange&lt;String&gt;)</code>'</p>
  </blockquote>
  <h3>attempt 4</h3>
  <pre><code>let 4: String = (Character(&quot;0&quot;)...Character(&quot;9&quot;)) + (Character(&quot;a&quot;)...Character(&quot;z&quot;))
  </code></pre>
  <blockquote>
  <p>Binary operator '+' cannot be applied to two '<code>ClosedRange&lt;Character&gt;</code>' operands</p>
  </blockquote>
  <h3>attempt 5</h3>
  <pre><code>let 5: String = String(Character(&quot;0&quot;)...Character(&quot;9&quot;)) + String(Character(&quot;a&quot;)...Character(&quot;z&quot;))
  </code></pre>
  <blockquote>
  <p>Cannot invoke initializer for type 'String' with an argument list of type '<code>(ClosedRange&lt;Character&gt;)</code>'</p>
  </blockquote>