On Wed, Jul 11, 2012 at 7:18 AM, Jason King <[email protected]> wrote:

> However, at the bottom, the 'returnString' variable is not called or
> set with 'var'.
>

That's because var is a declaration keyword. You only do that once to keep
that variable local in scope to the function within which it's declared.

Question. Once you 'var' scope a variable in a function, do any calls
> to that variable name within that function default to the 'var' scoped
> one?
>

Yes.


>
> I'm just wondering how that would work. Within a parent document, you
> have a variable 'returnString', and that parent document calls a
> function that has a 'var' scoped variable named 'returnString' as
> well. Which one gets used when the function calls 'returnString' ??
>

Completely depends on what you set the return variable name to in the
caller.

<cfset foo = 1 />

<cfset foo = someCFC.someMethod() />

At that point foo is overwritten by whatever is returned from the CFC
method. The variable *names* do not leak out of the CFC method.


-- 
Matthew Woodward
[email protected]
http://blog.mattwoodward.com
identi.ca / Twitter: @mpwoodward

Please do not send me proprietary file formats such as Word, PowerPoint,
etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html

-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

Reply via email to