What are the type declarations of the properties sc.name and sc.category? Do they just happen to hold String values or are they typed to enforce that they hold String values? Is there anything else unique about these properties? Are they in a custom namespace? Are they read-only? How were they populated in the first place?
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of simonjpalmer Sent: Monday, April 02, 2007 6: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()?

