In the original case, the "me" variable will be available to all methods within a given instance of the CFC.  Thus, if each user has an instance in the session scope, each one will have a private instance variable called "me".  In that construct, it will always be available as "variables.me" anywhere in the CFC.
 
You are also correct that if you say <cfset var me = structNew()> at the top of your init method than that variable will be available only inside init() -- you should avoid naming local variables the same as instance variables, as that can make your code confusing and makes it easy to code in hard-to-diagnose bugs.
 
 
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Marlon Moyer
Sent: Sunday, February 22, 2004 1:18 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Confused about var

I forgot to add that if I place the <cfset var me = structnew()> in the init function, then it will only be available in the init function right?

 

Marlon

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marlon Moyer
Sent: Sunday, February 22, 2004 3:02 PM
To: [EMAIL PROTECTED]
Subject: [CFCDev] Confused about var

 

Say with a CFC like this:

 

<cfcomponent>

            <cfset me = structnew()>

 

            <cffunction name=”init”>

 

            </cffunction>

 

</cfcomponent>

 

I can’t use the var keyword on the me structure, so will it be a shared instance among all instances of the CFC.  I’m trying to use this cfc in the session scope, and every session will have one of these cfc’s. 

 

Marlon

 

Reply via email to