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

Re: [sc-users] ? and ??



its like a little if statement to test if the thing was nil.

if the thing is not nil, it does not value the function, and returns the thing. if the thing is nil, it values the function and returns the result of that instead of the thing.

most commonly used like this:
	
thing = someSuppliedArgument ?? { Array.fill(18,{ 0.4.rand }) };

where we don't go through the trouble of building the array if the
someSuppliedArgument was something not nil.

its like doing this:

result =
	if(thing.isNil, {
		Array.fill(18,{ 0.4.rand })
	}, {
		thing
	});


of course the thing doesn't need to be a function, but it will
get .valued.

// no valueing
result = test ? default;

result = test ?? { ... make a default };



in the early crucial lib there was a version that
i still prefer the syntax of:

?!

as in "nothing ?  well then do this !"




On Saturday, December 28, 2002, at 02:45 PM, christian.hresko wrote:

hmmm... i still don't get it.

i looked in Nil.sc and Object.sc.  not much going on.

what is the name of this operator?

On Saturday, December 28, 2002, at 01:08  AM, ccos wrote:

last one was obviously a typo, read:

nil ?? { "foo".post }

apologies,
_c

On Saturday, December 28, 2002, at 04:56 PM, ccos wrote:

try,

nil ? 5
nil ? { "foo".post }
nil ?? { "foo.post" }

look in NIL.sc & Object.sc

best,
_c

On Saturday, December 28, 2002, at 02:58 PM, christian.hresko wrote:

what does ? do?
what does ?? do?

(4 ? 5).postln;
4

(4 ?? 5).postln;
4


x = FSinOsc;
y = FSinOsc;
z = LFSaw;

(x ? y).postln;
FSinOsc

(x ?? y).postln;
FSinOsc

(x ? z).postln;
FSinOsc

(x ?? z).postln;
FSinOsc


this is testing for what?

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


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


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


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



-felix