Created
February 20, 2011 13:17
-
-
Save Araq/835959 to your computer and use it in GitHub Desktop.
parseBool
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
proc parseBool(s: string): bool = | |
case normalize(s) | |
of "y", "yes", "true", "1", "on": result = true | |
of "n", "no", "false", "0", "off": result = false | |
else: raise newException(EInvalidValue, "cannot interpret as a bool: " & s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment