We don't have the definitions of sc.name and oc.category. Are they really typed as strings? Do they have the same length? Testing with "sc.name is String" is a good way to verify.
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of simonjpalmer Sent: Monday, April 02, 2007 3:14 PM To: [email protected] Subject: [flexcoders] question about string equality take a look at this code snippet... 01 // check one doesn't already exist with this name 02 bFound = false; 03 for (isc = 0; isc < ss.scenarios.length && !bFound; isc++) 04 { 05 sc = Scenario(ss.scenarios.getItemAt(isc)); 06 if (sc.name.valueOf() == oc.category.valueOf()) bFound = true; 07 } 08 if (!bFound) 09 { 10 // Make a new scenario 11 sc = PlanPointFactory.makeScenario(uli, null, true, false); 12 13 // add it to the snapshot 14 ss.addScenario(sc); 15 16 // add it to the local array of categories 17 oc.objects.push(sc); 18 } line 06 is the offending line. if I have: 06 if (sc.name == oc.category) bFound = true; the bFound flag never gets set true. I have to have the valueOf() function in order for the equality to fire correctly. This is not what I expected. I thought that regular equality would have sufficed here since sc.name and oc.category are both Strings. Why am I wrong and why do I need valueOf()?

