2 categories::Core, Common methods
3 related:: Guides/Control-Structures
4 summary:: conditional execution
9 if ( [false, true].choose, // Boolean expression (chooses one at random)
10 { "expression was true".postln }, // true function
11 { "expression was false".postln } // false function
16 z = if (a < 5, { 100 },{ 200 });
23 the condition ugen is 0 / 1
28 if( LFNoise1.kr(1.0,0.5,0.5) , SinOsc.ar, Saw.ar )
33 subsection:: optimization
35 the functions will be inlined, which plucks the code from the functions and uses a more efficient jump statement.
49 4 E6 SendSpecialBinaryArithMsg '=='
50 5 F8 00 06 JumpIfFalse 6 (14)
51 8 42 PushLiteral "hello"
52 9 A1 00 SendMsg 'postln'
53 11 FC 00 03 JumpFwd 3 (17)
54 14 41 PushLiteral "hello"
55 15 A1 00 SendMsg 'postln'
57 a FunctionDef in closed FunctionDef
63 failure to inline due to variable declarations
76 WARNING: FunctionDef contains variable declarations and so will not be inlined.
77 in file 'selected text'
81 -----------------------------------
85 4 E6 SendSpecialBinaryArithMsg '=='
86 5 04 00 PushLiteralX instance of FunctionDef in closed FunctionDef
87 7 04 01 PushLiteralX instance of FunctionDef in closed FunctionDef
88 9 C3 0B SendSpecialMsg 'if'
90 a FunctionDef in closed FunctionDef
105 4 E6 SendSpecialBinaryArithMsg '=='
106 5 F8 00 06 JumpIfFalse 6 (14)
107 8 42 PushLiteral "hello"
108 9 A1 00 SendMsg 'postln'
109 11 FC 00 03 JumpFwd 3 (17)
110 14 41 PushLiteral "hello"
111 15 A1 00 SendMsg 'postln'
113 a FunctionDef in closed FunctionDef