Last active
November 17, 2015 21:17
-
-
Save kwstannard/18b648bc000fc12818cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment