With Ruby 3 hash pattern matching, is it possible to specify that the rest
contains only allowed keys?
So far I only came up with this:
opts = { value: 5, limit: 10 } # valid
# opts = { value: 5 } # valid
# opts = { value: 5, foo: 10 } # not valid
case opts
in value:, **rest if rest.nil? || (rest.keys - %i[limit]).empty?
end
Something inspired by Flowtype might be in value:, limit?:
or even
in value: Integer, limit?: Integer