compiler.if_


compiler.if_(condition, consequent, alternative)
compiler.if_multi(conditions_consequences)
compiler.when_(condition, consequent)
compiler.case_(conditions_consequences)   
      

Return the intermediate language code required for conditional branching.

Examples:


// if (1 < 2) 100 else 200          
eval(compiler.if_(compiler.call('`<`, [1, 2]), 100, 200))
// 100

// if (1 > 2) 100 else if (2 > 1) 200 else 300
eval(compiler.if_multi([[compiler.call('`>`, [1, 2]), 100],
                        [compiler.call('`>`, [2, 1]), 200],
                        ['else, 300]]))
// 200

// case (x) 100 -> a | 200 -> b | else -> c
let x = 200  
eval(compiler.case_('x, [[[100], "a"], [[200], "b"], ['else, "c"]]))
// b
      

Also see:

compiler


Core Module Index | Contents