I've been banging my head against the wall for the past 30 minutes trying to figure out why this simple code doesn't work. All it does is check to see if at least one command line argument has been specified.
(defn check_args []
(if (first *command-line-args*)
println "value is not nil"
println "value is nil"))
(check_args)
When I run the code, I end up with a runtime exception that says:
java.lang.RuntimeException: Too many arguments to if
I'm sure it's something simple, but for the life of me I can't figure out where the problem is. The code pulling the first item off of the sequence returns the first item in the sequence, or nil if it doesn't exist, so it seems pretty straight-forward.
You lose parentheses - common mistake.
Try this
(defn check_args []
(if (first *command-line-args*)
(println "value is not nil")
(println "value is nil")))
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