How to pass optional named arguments in Ruby 2.0 -


Is there any way to logically be an alternative, I know if the caller is set or not ?

The use of a logic does not work by default as zero because there is no way to pass the caller to zero Default value is

  def foo (option = {}) # ... bar (option) end def bar (option)   

= {} ) Add options.fetch (: name, 'unknown') # = & gt; With 'Ruby 2.0' designated arguments, 'unknown' end

:

  def foo (name: void) # ... bar (name: name) end Def bar (name: 'unknown') # ... name name # = & gt; Zero, because zero is clearly passed from end to `foo ' 

Perhaps the best way would be to go:

  def bar (name: zero) name || = 'Anonymous' puts the end of the name  

Comments