Barney Boisvert wrote:
> <cfset variables.variables.test = "" />
> <cfoutput>
> #isDefined("variables.test")#<br />
> #structKeyExists(variables, "test")#
> </cfoutput>
>
> isDefined() returns true, structKeyExists() returns false.

So an empty value in a defined var comes up as nonexistent.  Yours and
Sean's points are well taken insofar as the efficiency of one vs. the
other are concerned, but this behavior is inconsistent with the avowed
purpose of the function.

Add this to the bottom of your code:

<cfdump var="#variables#" label="local scope">

You'll see that the struct is there, and the key exists.  Its just
empty, which to me is nto the same condition as nonexistent.  The docs
fail to mention this quirk, but they do say it is "sometimes" a usable
substitute for isdefined.  Too bad thats where the specifics end.

You would have to build an app with this difference in behavior in
mind.  You couldn't just substitute one for the other to gain a speed
improvement, which is a bummer.

--
--Matt Robertson--
MSB Designs, Inc.
mysecretbase.com
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to