title: Does Kotlin have a Result type like Swift
body: <p>Swift has a <code>Result</code> type that is declared like this</p>
  
  <pre class="lang-swift prettyprint-override"><code>enum Result&lt;Success, Failure: Error&gt; {
      case success(Success)
      case failure(Failure)
  }
  </code></pre>
  
  <p>Which can be used like this:</p>
  
  <pre class="lang-swift prettyprint-override"><code>enum FooError: Error {
      case fizzReason
      case barReason
      case bazReason
  }
  
  func returnResult() -&gt; Result&lt;String, FooError&gt; { 
      // ... Just imagine this method returns an error
  }
  
  switch returnResult() {
  case .success(let string):
      print(s)
  case .failure(.fizzReason):
      // do something
  case .failure(.barReason):
      // do something
  case .failure(.bazReason):
      // do something
  }
  </code></pre>
  
  <p>Does Kotlin have a similar Data Type which can be used in the same manner?</p>