You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python has this function isInstance which tells you if a value is an instance of a class, i.e.
dict = {}
if isInstance(dict, dictionary):
# do something
it would be nice to have some sort of equivalent in chuck, specifically for the case of storing different subclasses in an array:
[new SinOsc, new SndBuf, new LiSa] @=> UGen ugens[] => dac;
// this won't work
// 220 => ugens[0].freq;
// this works, but you need to keep track of which
// index is a sinosc
330 => (ugens[0] $ SinOsc).freq;
// what if we had something like this?
int i;
while (true) {
if (Type.isInstance(ugens[i], SinOsc) {
330 => (ugens[i] $ SinOsc).freq;
}
(i + 1) % 3 => i;
}
eon => now;
That way, even if the type info gets lost because it needs to be cast to a more general type, we can still get back to its original type
The text was updated successfully, but these errors were encountered:
Python has this function isInstance which tells you if a value is an instance of a class, i.e.
it would be nice to have some sort of equivalent in chuck, specifically for the case of storing different subclasses in an array:
That way, even if the type info gets lost because it needs to be cast to a more general type, we can still get back to its original type
The text was updated successfully, but these errors were encountered: