title: Can I initialize a class with a variable which is defined by a function inside that class in Swift 2?
body: <p>Is it possible that the variable which initializes my class is computed by a function inside that class?</p>
  
  <p>I first initialize MyClass:</p>
  
  <pre><code>let MyClass = MyClass()
  </code></pre>
  
  <p>Second, this would be the code in the class:</p>
  
  <pre><code>class MyClass {
      var myString = computeRandomString()
  
      func computeRandomString() -&gt; String {
          piece of code
          return(randomString)
      }
  }
  </code></pre>
  
  <p>Whenever I create an instance of MyClass I want the myString to be a randomString. In order for that I made a function within the same class. </p>