title: Functions with Option Parameters, or using an empty Dictionary as a Default Parameter
body: <p>This is what I want:</p>
  
  <p>A function in swift that can take an optional parameter, so the following calls to the function <code>myFunc</code> would both work fine:</p>
  
  <pre><code>// assume we have a Dictionary like this
  let dict=["key":"value"]
  
  myFunc()
  myFunc(dict)
  </code></pre>
  
  <p>The function <code>myFunc</code> works like this:</p>
  
  <p>Any Dictionary passed into <code>myFunc</code> is merged with a Dictionary inside <code>myFunc</code>. If no Dictionary is passed into <code>myFunc</code> then the Dictionary inside <code>myFunc</code> will be used as is.</p>
  
  <hr>
  
  <p>That's what I want to achieve in Swift. This is how I've been going about it:</p>
  
  <p>It seems that you cant just omit parameters completely, but after some reading about I have been looking into default parameters. I want the parameter to be of type Dictionary, but if there is no parameter specified then I want nothing, or at least, an empty Dictionary. I have declared an empty Dictionary like so:</p>
  
  <pre><code>let emptyDict = Dictionary&lt;String,String&gt;()
  </code></pre>
  
  <p>And then I declare my function with a default parameter like so:</p>
  
  <pre><code>func myFunc(paramDict:Dictionary = emptyDict){ ... }
  </code></pre>
  
  <p>This gives me the following error:</p>
  
  <pre><code>Reference to generic type 'Dictionary' requires arguments in &lt;...&gt;
  </code></pre>
  
  <p>I am assuming here it is complaining because I am using an empty dictionary as a parameter.</p>
  
  <p>Can anybody show me how to build a function in Swift that can function like I want <code>myFunc</code> to?</p>