/trunk/Examples/ruby/hashargs/runme.rb

# · Ruby · 26 lines · 17 code · 5 blank · 4 comment · 0 complexity · 1be6e4dbe12497134240a0819054aaf7 MD5 · raw file

  1. require 'example'
  2. include Example
  3. # Pass arguments in as one or more key-value pairs
  4. setVitalStats("Fred",
  5. 'age' => 42,
  6. 'weight' => 270
  7. )
  8. # The order doesn't matter
  9. setVitalStats("Sally",
  10. 'age' => 29,
  11. 'weight' => 115,
  12. 'height' => 72
  13. )
  14. # Can also pass a hash directly
  15. params = {
  16. 'ears' => 2,
  17. 'eyes' => 2
  18. }
  19. setVitalStats("Bob", params)
  20. # An empty hash is fine too
  21. setVitalStats("Joe", {})