Idiomatic Scala: Mapping over option depending on condition
<p>I have two <code>val</code>s, a <code>condition</code> and an <code>option</code>. Note that <code>condition</code> is a simple boolean, not depending on the option's value.</p>

<p>If <code>condition</code> holds true, I would like to map over the option to convert it to a result value. In all other cases, I would like to return a <code>defaultResult</code>.</p>

<p>This works and is quite readable, but I dislike the duplication of <code>defaultResult</code>:</p>

<pre><code>val result = if (condition) {
  option.map(valueToResult).getOrElse(defaultResult)
} else {
  defaultResult
}
</code></pre>

<p>My second approach does not have duplications, but I dislike the fact that filter is abused for something that is not actually dependent on the option's value:</p>

<pre><code>val result = option.filter(_ =&gt; condition).map(valueToResult).getOrElse(defaultResult)
</code></pre>

<p>What's a more idiomatic or otherwise better approach in Scala?</p>