[chuck-users] How to compare strings?

Ge Wang gewang at CS.Princeton.EDU
Fri Sep 16 01:25:04 EDT 2005

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 queue) and this rather unforeseen use of 
associative arrays.


More information about the chuck-users mailing list