[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Or



But testing this "function" principle with "||" seems to work too...

a = 0;
if((a == 0) || {"2nd test".postln; 0.5.coin}) { "true".postln } {"false".postln };

So is there any difference between "or:" and "||" (as with "and:" and "&&") ?

T

Le 6 oct. 05, à 23:35, TomD a écrit :

Le 29 sept. 05, à 16:53, James Harkins a écrit :

if((a == 1) or: { "2nd test".postln; 0.5.coin}) { "true".postln } {
"false".postln };

(a == 0) is false, so we have to run the second test to get the result.

The second test has to be written as a function for short-circuiting to work.


I guess you mean "(a == 1) is false, so we have to run(...)"

Ok nice to understand more practically "or:" and "and:", thanks a lot.

It seems to work too, writing that same example that way, as with "&&" and "||" (the way I do until now):

if((a == 1) or: { "2nd test".postln; 0.5.coin}, { "true".postln }, {"false".postln });


_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users