That "glitch" is only relevant if you specify a scope name for the first
argument of structKeyExists. So the functional difference will only be
there if you name a structure with a scope name. The fact that the var is
empty is only because that's what I assigned it to initially. You can
change it to something else and the functionality won't change.
The point I was making was simply that isDefined does a lot more work, even
for seemingly simple lookups.
Cheers,
barneyb
> -----Original Message-----
> From: Matt Robertson [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 12, 2004 3:51 PM
> To: CF-Talk
> Subject: Re: StructKeyExists() vs IsDefined()
>
> 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.
>
> --
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- RE: StructKeyExists() vs IsDefined() Spike
- Re: StructKeyExists() vs IsDefined() Sean Corfield
- RE: StructKeyExists() vs IsDefined() Spike
- Re: StructKeyExists() vs IsDefined() Sean Corfield
- Re: StructKeyExists() vs IsDefined() Simon Horwith
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- RE: StructKeyExists() vs IsDefined() Spike
- Re: StructKeyExists() vs IsDefined() Matt Robertson
- Re: StructKeyExists() vs IsDefined() Matt Robertson
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- RE: StructKeyExists() vs IsDefined() Spike
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- RE: StructKeyExists() vs IsDefined() Spike
- Re: StructKeyExists() vs IsDefined() Stephen Moretti (cfmaster)
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- Re: StructKeyExists() vs IsDefined() Sean Corfield
- Re: StructKeyExists() vs IsDefined() Stephen Moretti (cfmaster)
- Re: StructKeyExists() vs IsDefined() Sean Corfield
- Re: StructKeyExists() vs IsDefined() Stephen Moretti (cfmaster)
- Re: StructKeyExists() vs IsDefined() Matt Robertson