Contents    Page-10    Prev    Next    Page+10    Index   

IF statement

The if statement in Clojure has the forms:

(if test thencode )

(if test thencode elsecode )

The test is interpreted as follows:

The if statement returns the value of either the thencode or elsecode; cf. the C form test ? thenval : elseval


(if true 2 3)       ->  2

(if false 2 3)      ->  3

(if '() 2 3)        ->  2

(if (+ 2 3) 2 3)    ->  2