Issue #17718 has been updated by Hanmac (Hans Mackowiak).


the ArgumentError can be raised manually when going to raise an Exception anyway

@nobu the problem i see there right now if rest keywords should include default param / null.

because the pattern matching above only cares about the existence of the symbol key in case, and doesn't check if the value might be null


what works but is ugly is this:

```ruby
def getParam(city: nil, state: nil, zip: nil)
  case {city: city, state: state, zip: zip}.compact
```

----------------------------------------
Feature #17718: a method paramaters object that can be pattern matched against
https://bugs.ruby-lang.org/issues/17718#change-90933

* Author: dsisnero (Dominic Sisneros)
* Status: Open
* Priority: Normal
----------------------------------------
```ruby
def get_perdiem(city: nil, state: nil, zip:nil)

  case parameters_match  # (return an object of the parameters we can pattern match on)
  in {zip: zip}
     find_perdiem_by_zip(zip)
  in {state: s, city: c}
     find_perdiem_by_state_and_city(s, c)
  in { state: s}
     find_perdiem_by_state(s)
  else
     raise 'need combination of zip, city,state'
  end
end
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>