StructKeyExists(scope,'var') instead of isDefined()
Just came across some articles that explained the following, if you use ColdFusion MX it's better to check for a variable in their own scope structure than checking the variable with isDefined(). Why you ask... this is why... An isDefined() checks all the scopes for a particular variable even when you say isDefined("session.var"). This will still look in other scopes than the session scope.
In MX all the variables are structures and you can check if a variable is in a particular scope with StructKeyExists(scope,"var")
When checking for a variable it is therefore better to use StructKeyExists() because ColdFusion will only look in the given scope for the variable.
NOTE: Do not use the structKeyExists() with CFC's because the URL scope does not exist in a CFC, when not using URL parameters in your CFC you are good to go :-)
6450 viewed | 2 opinion(s) | del.icio.us | Digg it | Tjarko @ 11/08/04 0:00 cet



