Executing multiple statements in if-else without nullpointer exception

Use do:

(defn status []
  (if server 
    (do
      (println "server is up and running")
      (println "connections:" (connection-count server)))    
    (println "server is down")))

In Lisps, generally, you can’t just add parens for grouping.

((println "foo") (println "foo"))

Here, the return value of the first (println "foo") will be tried to be called (as a function), with the return value of the second as an argument. Those are very basic evaluation rules, so I suggest that you hit some introductory books or documentation about Clojure or Lisps in general.

From the evaluation section of the Clojure homepage:

Non-empty Lists are considered calls
to either special forms, macros, or
functions. A call has the form
(operator operands*).

Macros or special forms may “break” this rule.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)