First and last stupid Ruby question for the year...I hope
Posted: Fri Dec 27, 2019 4:06 am
Forgive me, my only previous exposure to Ruby was in Sketchup macros...
I encountered this snippet inside a toolbox module named 'Delay'. (The question of how it differs from the otherwise identical 'Delay' primitive just above it is best left for another time.)
The last couple of lines look like they're just doing a standard increment-and-wrap, except the expression
index = (index<delay)&index;
screams "SYNTAX ERROR!!" in pretty much any language I've ever encountered. I can live with the idea that 'False' evaluates to 0 in a numeric context, but for this to work, it has to assume that 'True' evaluates to all 1s and 'index' is being treated as an array of bits. (I'm afraid to even ask why 'index' is declared "float".)
I encountered this snippet inside a toolbox module named 'Delay'. (The question of how it differs from the otherwise identical 'Delay' primitive just above it is best left for another time.)
Code: Select all
streamin in;
streamout out;
streamin delay;
float mem[44100];
float index;
stage(2)
{
out = mem[index];
}
stage(3)
{
mem[index] = in;
index = index + 1;
index = (index<delay)&index;
}
The last couple of lines look like they're just doing a standard increment-and-wrap, except the expression
index = (index<delay)&index;
screams "SYNTAX ERROR!!" in pretty much any language I've ever encountered. I can live with the idea that 'False' evaluates to 0 in a numeric context, but for this to work, it has to assume that 'True' evaluates to all 1s and 'index' is being treated as an array of bits. (I'm afraid to even ask why 'index' is declared "float".)