Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.40 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. user_builder = lambda do |first_name, last_name, *options|
  2.   # options = [{first_name_only: true, other_random_option: false}]
  3.   if !options.empty? && options.first[:first_name_only]
  4.     return first_name.capitalize
  5.   else
  6.     return first_name.capitalize + ' ' + last_name.capitalize
  7.   end
  8. end
  9.  
  10. puts user_builder.call("Dan", "DeMeyere", :first_name_only => true, :other_random_option => false) # => outputs Dan