function | since v0.0-1798 | clojure.core/char | Edit |
(char x)
Converts a number x
to a character using String.fromCharCode(x)
from
JavaScript.
(char 81)
;;=> "Q"
(char "Q")
;;=> "Q"
(char "foo")
;; Error: Argument to char must be a character or number
Coerce to char
(defn char
[x]
(cond
(number? x) (.fromCharCode js/String x)
(and (string? x) (== (.-length x) 1)) x
:else (throw (js/Error. "Argument to char must be a character or number"))))