Okay, so I'm in a Hal Helms class and neither he nor I can figure out this
one..... In the following CFC, if you set a variables.address at the
beginning that is the same object type as is used in the init function, the
variables.address supercedes the init setAddress() function. Why? Why? Why?

Note that if you set variables.address to a junk object, it correctly gets
overwritten by the init function. Or, if you set it to a string, it
correctly gets overwritten.

<cfcomponent displayname="Cat">
<cfscript>
variables.name = '';
variables.address = createObject('component',
'ColdfusionFoundations.CFCs.Address').init('','','','','','');
</cfscript>
<!--- Init --->
<cffunction name="init" access="public" returntype="Cat" output="false">
<cfargument name="name" required="true" type="string">
<cfargument name="address" required="true" type="address">
<cfset setName(arguments.name) />
<cfset setAddress(arguments.address) />
<cfreturn this />
</cffunction>

<!--- Setters --->
<cffunction name="setName" access="private" returntype="void"
output="false">
<cfargument name="name" required="true" type="string">
<cfset variables.name  = arguments.name />
</cffunction>

<cffunction name="setAddress" access="private" returntype="void"
output="false">
<cfargument name="address" required="true" type="address">
<cfset variables.address  = arguments.address />
</cffunction>

<!--- Getters --->
<cffunction name="getName" access="public" returntype="string"
output="false">
<cfreturn variables.name />
</cffunction>

<cffunction name="getAddress" access="public" returntype="address"
output="false">
<cfreturn variables.address />
</cffunction>

</cfcomponent>

--
Deanna Schneider
UWEX-Cooperative Extension
Interactive Media Developer
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to