title: Method call with option value or default parameter in Scala
body: <p>I'm rather new to Scala and stumbled upon a small little issue that keeps bothering me. Let's say there is some method with default parameter</p>
  
  <pre><code>def foo(v: Any = "default"): String = s"called with parameter '$v'"
  </code></pre>
  
  <p>and an Option <code>val opt: Option[String]</code>.
  How to call this method with either the option value (if defined) or the default parameter?
  I mean despite the obvious solution</p>
  
  <pre><code>val result = if (opt.isDefined)
                 from.here.to.foo(opt.get)
               else
                 from.here.to.foo()
  </code></pre>
  
  <p>and having to type the method with (possibly long) object chain twice? Not to mention having more than one optional/default parameter...</p>
  
  <hr>
  
  <p>All I could come up with is the unhelpful helper</p>
  
  <pre><code>def definedOrDefault[A, B](opt: Option[A], f0: =&gt; B, f1: A =&gt; B): B =
    if (opt.isDefined) f1(opt.get) else f0
  </code></pre>
  
  <p>but when not being able to mention default parameters in higher order functions... that's it. Reminds me of the bad old days with Java where method overloading creates the same problem.</p>