/usr/share/SuperCollider/HelpSource/Classes/Nil.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | class::Nil
categories::Core
summary::Represents uninitialized data
description::
Nil has a single instance named nil and is used to represent uninitialized data,
bad values, or terminal values such as end-of-stream.
instancemethods::
private::do, reverseDo, pairsDo, collect, select, reject, detect, collectAs, selectAs, rejectAs, pop, source, source_, changed, addDependant, removeDependant, release, update, swapThisGroup, performMsg, remove, seconds_, throw, superclassesDo, !?, play, printOn, storeOn, archiveAsCompileString, set, addDependant
method::isNil
Answers true because this is nil. In class link::Classes/Object:: this message is defined to answer false.
code::
[1, 2, nil, 3].collect(_.isNil);
::
method::notNil
Answer false. In class link::Classes/Object:: this message answers true.
code::
[1, 2, nil, 3].collect(_.notNil);
::
method::?
return first non-nil argument. Since this IS nil then return anObject.
In class link::Classes/Object::, ? is defined to answer the receiver.
code::
[1, 2, nil, 3].collect { |x| x ? -1 }; // replace nil by -1
::
method::??
If the receiver is nil, evaluate the function and return the result. Since this IS nil, then evaluate the function and return the result. In class link::Classes/Object::, ?? is defined to answer the receiver.
code::
[nil, 2, nil, 3].collect { |x| x ?? { 100.rand } }; // replace nil by a random number
::
method::booleanValue
Returns false.
code::
[1, 2, nil, 3].collect(_.booleanValue);
// compare:
[true, false, false, true].collect(_.binaryValue);
::
method::rate
Returns nil.
method::numChannels
Returns nil.
method::isPlaying
Returns false.
method::dependants
Returns an empty IdentitySet.
method::awake
Returns nil.
method::nextTimeOnGrid
Returns clock.nextTimeOnGrid.
method::asQuant
Returns Quant.default.
method::matchItem
Returns true.
See also link::Reference/matchItem::.
code::
[3, 2, 1].select(nil.matchItem(_))); // returns all
// compare:
[3, 2, 1].select([1, -1, 2].matchItem(_))); // returns only those in the key collection
::
method::asCollection
Returns empty array.
method::get
Returns prevVal.
method::asSpec
Returns the default ControlSpec
method::handleError
Either report error or inspect error and halt execution.
method::push
Executes function.
method::appendStream
Returns stream.
subsection::Dependancy
All the messages for the Dependancy protocol (See class link::Classes/Object::) are defined in class Nil
to do nothing. This eliminates the need to check for nil when sending dependancy messages.
subsection::Other Methods
Many other messages are defined in class Nil to do nothing. This eliminates the need to check for nil.
subsection::Generic Collectors
There are a number of methods that can be applied to nil so that variables do not need to be initialized. Nil is just the "ground" (default case) from which the rest is bootstrapped.
method::add
Returns an array with the value. This makes it unnecessary to initialize when adding to a variable.
code::
x = nil;
x = x.add(8); // returns an array
x = x.add(7); // appends to the array
::
method::addAll
Returns an array with all the values. This makes it unnecessary to initialize when adding to a variable.
code::
x = nil;
x = x.addAll([0, 2, 1, 2]); // returns an array
x = x.addAll(7); // single objects are converted
::
method::remove
For nil, it just returns nil. This makes it unnecessary to initialize when removing from a variable and adding to it again.
code::
x = nil;
x.remove(1); // stays nil, returns nil
x = x.addAll([0, 2, 1, 2]); // returns an array
x.remove(1); // returns 1
x;
::
method::++
Returns an array with all the values. This makes it unnecessary to initialize when adding to a variable.
code::
x = nil;
x = x ++ [7, 8, 9]; // returns the receiver
x = x ++ [3, 0, 1, 2]; // adds to the array
::
method::addFunc
Returns a function or a FunctionList.
This method is used to add multiple functions to already existing ones.
code::
f = nil;
f = f.addFunc { "----------****".scramble };
f = f.addFunc { 1.0.rand };
f.value;
::
method::removeFunc
This method is used to remove multiple functions from already existing ones. For Nil, it just returns itself.
code::
f = { 1.0.rand };
g = { "you have produced a random value".postln };
f = f.addFunc(g);
f.value;
f.removeFunc(g);
f.value;
::
method::transformEvent
This method is used to operate on events which are passed through the system as an argument.
code::
// for Nil: return the argument unmodified (an event).
nil.transformEvent((x: 8));
// for Dictionary (and thus for Event): add to the argument.
(y: 100, z: 1).transformEvent((x: 8));
// for Association: add the association to the event
(\a -> \x).transformEvent((x: 8));
// for Function: use the function receive the event as argument.
{ |event| event.use { ~x = ~x + 1 }; event }.transformEvent((x: 8));
::
|