This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def address_method(city: "Bloomington", state: "IN", street: "123 fake st") | |
print x,y,z,"\n" | |
end | |
input = {city: "Indianapolis", street: "321 faux st", zip: "12345"} | |
address_method(input_address) # => ArgumentError: unknown keyword: zip | |
addr_mthd = method(:address_method) | |
acceptable_keywords = addr_mthd.parameters.select{|p| p[0] == :key}.map(&:last) | |
accepted_input = input.select{|(k,v)| acceptable_keywords.include?(k)} | |
address_method(accepted_input) # => IndianapolisIN321 faux st |