title: switch and cannot find variable in scope
body: <p>Why should I create a variable outside of switch/case?
  For example this code will have an error <code>Cannot find 'size' in scope</code>:</p>
  <pre><code>func sizeCheckNoVar(value: Int) -&gt; String {
          switch value {
          case 0...2:
              let size = &quot;small&quot;
          case 3...5:
              let size = &quot;medium&quot;
          case 6...10:
              let size = &quot;large&quot;
          default:
              let size = &quot;huge&quot;
              
          }
          return size
      }
  </code></pre>
  <p>There is a default condition and AFIK all options are covered.</p>
  <p>In the same time this code will be fine:</p>
  <pre><code>func sizeCheckVar(value: Int) -&gt; String {
      var size: String
      switch value {
      case 0...2:
          size = &quot;small&quot;
      case 3...5:
          size = &quot;medium&quot;
      case 6...10:
          size = &quot;large&quot;
      default:
          size = &quot;huge&quot;
          
      }
      return size
  }
  </code></pre>
  <p>PS I saw this question <a href="https://stackoverflow.com/questions/64901490/cannot-find-variable-in-scope">Cannot find variable in scope</a> , but I want to know <strong>why</strong> instead of <strong>how to avoid</strong></p>