Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A Clojure function that always returns nil

Tags:

clojure

Is there a function in Clojure that always returns nil no matter what the input is?

I know I could write (fn [_] nil) but is there a built-in function?

like image 880
nboon Avatar asked Dec 05 '22 17:12

nboon


1 Answers

You can use constantly to return a function which always returns the given value e.g.

(constantly nil)

Note the returned function takes an arbitrary number of parameters while yours only allows one.

like image 111
Lee Avatar answered Jan 16 '23 07:01

Lee