title: returning different return types in scala
body: <p><strong>Is there a way to return different return types from a single method in scala?</strong></p>
  
  <p>For example, if I have a <code>load()</code> method, I would like to return different data types depending on the object that called this method.</p>
  
  <pre><code>def load(path: String):&lt;return type&gt; 
  {
      // if this instance is of type "type1", do some processing on this object, 
      // and return object of type "type1"
  
      // else if this instance is of type "type2", do some processing on this object,
      // and return object of type return "type2"
   }
  </code></pre>