16 Sep
2005
16 Sep
'05
1:25 a.m.
Greetings Manfred,
I figured out that 'associative arrays' can be used for string comparison, ie. by associating unique numbers with the strings to be checked. For example
int x[0]; 1 => x["abc"]; 2 => x["def"]; ...
Now a string variable s can be checked for equality by writing
if(x[s]==x["abc"])...
Note that this works without explicit use of the numbers.
We hereby present you with the award for "best work-around of the month necessitated by a bug in ChucK". This hack is simply fantastic (especially since strings are quite broken in the language). Thanks for pointing out the string comparison bug (now on the 1.2.0.1 queue) and this rather unforeseen use of associative arrays. Best, Ge!