Reputation: 317
I'm a new student of Clojure and don't get why "nil" is returned in REPL when I call functions that do not return values.
Above an example:
(println "Hello Nil")
nil
What type of evaluation process are made to reach "nil"?
Upvotes: 3
Views: 2035
Reputation: 29958
It is a convention of functional languages like Clojure that every function needs to return exactly one value. For functions like println
that are intended to perform side effects (like printing to the screen), it is not always clear what the return value could or should be.
In these cases, nil
is a placeholder value that means "nothing" or "not applicable".
Upvotes: 12