Skip to content

Instantly share code, notes, and snippets.

@Araq
Created February 20, 2011 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Araq/835959 to your computer and use it in GitHub Desktop.
Save Araq/835959 to your computer and use it in GitHub Desktop.
parseBool
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