Jeff Small wrote:
> From: "Jochem van Dieten"
>> Jeff Small wrote:
>>>
>>> I'm struggling with "this". I don't understand even from Seans's post what
>>> purpose it serves to return "this" when you're using something like CFOBJECT
>>> or "CreateObject()" which creates an instance of an object anyway...
>>
>> Because that works with cfobject and createobject(), but not with
>> cfinvoke. (read on)
>
> I read on, and I still kinda don't understand when you say, "that works with
> cfobject and createobject(), but not with cfinvoke.".
>
> So you're saying that if I wanted to use CFINVOKE, that I wouldn't be able
> to unless my init() method was returning "this"?
Yes.
If you use cfinvoke you use 'throwaway' objects. In one call, you
create the object, initiaize it, use it and discard it again. The
only way to call multiple methods of an object is to have the
first one return an instance of the object, and then continue to
use that instance.
>> If you have your setters return "this" too, you can chain them
>> together:
>>
>> <cfset variables.myCFC.setDSN("dsn").setMode("READONLY")>
>
> Okay, "that" makes sense. You're able to do that because both methods
> (init() and setMode() both return "this"?
Yes.
Jochem
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - CFDynamics
http://www.cfdynamics.com
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188893
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54