title: Swift: Recursive Value Type
body: <p>I have a structure in which I want to have a global variable of type Struct?. This example is essentially a briefer version of the structure I am actually creating.</p>
  
  <pre><code>struct SplitString { //splits a string into parts before and after the first "/"
  
      var preSlash: String = String()
      var postSlash: SplitString? = nil
  
      init(_ str: String) {
          var arr = Array(str)
          var x = 0
          for ; x &lt; arr.count &amp;&amp; arr[x] != "/"; x++ { preSlash.append(arr[x]) }
          if x + 1 &lt; arr.count { //if there is a slash
              var postSlashStr = String()
              for x++; x &lt; arr.count; x++ {
                  postSlashStr.append(arr[x])
              }
              postSlash = SplitString(postSlashStr)
          }
      }
  
  }
  </code></pre>
  
  <p>However, it throws the error:</p>
  
  <pre><code>Recursive value type 'SplitString' is not allowed
  </code></pre>
  
  <p>Is there any way to get around this? Any help would be great. Thanks :)</p>
  
  <p>Edit:
  In case it is relevant, I am programming on iOS, not OSX.</p>
  
  <p>Edit:
  If I have:</p>
  
  <pre><code>var split = SplitString("first/second/third")
  </code></pre>
  
  <p>I would expect split to be:</p>
  
  <pre><code>{preSlash = "first", postSlash = {preSlash = "second", postSlash = {preSlash = "third",
  postSlash = nil}}}
  </code></pre>