Created
May 23, 2012 22:57
-
-
Save fj/2778358 to your computer and use it in GitHub Desktop.
Spot the subtle error
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
class CountrySearch | |
# Return the phone country code matching a particular | |
# two-letter country code (e.g. 'FR' will get France's | |
# country code, which is 33). | |
def self.country_code_for_alpha2(code) | |
return ArgumentError unless code =~ /^..$/ | |
return nil unless c = Country[code] | |
c.country_code | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You probably want to
raise ArgumentError