How to map java.util.Optional<Something> to Something? in Kotlin
<p>I have a method that returns <code>java.util.Optional&lt;Something&gt;</code>.
I want to use that method from Kotlin, and I want my result to be <code>Something?</code>, not <code>Optional&lt;Something&gt;</code></p>

<p>How to do that in Kotlin, in idiomatic way? </p>

<p>calling <code>.orElse(null)</code> on <code>Optional</code> gives me <code>Something?</code> indeed, but it does not look good. Kotlin does not complain if I write  <code>val msg: Something = optional.orElse(null).</code> (<code>msg</code> is declared as  <code>Something</code>, not <code>Something?</code>- I loose compile-type check).</p>

<p>I use Kotlin 1.0.3</p>