function | since v1.11.50 | Edit |
(parse-boolean s)
Parse strings "true" or "false" and return a boolean, or nil if invalid. Note that this explicitly excludes strings with different cases, or space characters.
(defn parse-boolean
[s]
(if (string? s)
(case s
"true" true
"false" false
nil)
(throw (js/Error. (parsing-err s)))))