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


@dsisnero

this is even more problematic because ruby doesn't know which parameter should be at which position there
it may not know which param you want at which in your in comparison, especially if you mix key args with non key args

You can still use args for this

```ruby
def get_param(name, **args, &error)
  case args
  in {city: String, state: String, zip: String}
    puts 'all method types matched against'
  in {city: String, state: String}
    puts 'only city and state matched'
  end
end
```

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

* 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>