Something wrong with
(def b [08])
java.lang.NullPointerException: null
but
(def b [8])
is OK
why?
I know nothing about clojure, but in many languages, an integer literal that starts with a zero is interpreted as octal (base 8). And 8 is an invalid octal digit.
From a quick experiment at Try Clojure:
> (def b [08])
java.lang.NumberFormatException: Invalid number: 08
> (def b [07])
#'sandbox155/b
It appears that this is indeed your problem.
Don't start integers with a leading zero (e.g. 08), unless you actually intend octal notation.
@Jonathon Reinhart is right, according to the LispReader.java :(https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L65) :
static Pattern intPat =
Pattern.compile(
"([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?");
The part 0([0-7]+) in the pattern prove this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With