title: How to pass optional named arguments in Ruby 2.0
body: <p>Is there a way for an argument to be truly optional so I know if it was set by caller or not?</p>
  
  <p>Having an argument use <code>nil</code> as the default does not work because there is no way to know if the caller passed <code>nil</code> or it is the default value for the argument.</p>
  
  <p>Before named arguments, in Ruby 1.9, using an options hash:</p>
  
  <pre><code>def foo(options = {})
    # …
    bar(options)
  end
  
  def bar(options = {})      
    puts options.fetch(:name, ‘unknown’) # =&gt; 'unknown'
  end
  </code></pre>
  
  <p>With Ruby 2.0 named arguments:</p>
  
  <pre><code>def foo(name: nil)
    # …
    bar(name: name)
  end
  
  def bar(name: ‘unknown’)
    # …
    puts name # =&gt; nil, since nil is explicitly passed from `foo`
  end
  </code></pre>