Why would you return 'this' from the init function? 'This' is not a pointer
to the object, so what good does it do the method caller?
Method chaining. It allows the following convenient idiom:
<cfset obj = createObject("component","mycfc").init() />
"this" *is* a reference to the object (not a pointer - there are no pointers in Java or CF).
It can be very convenient to have all mutators (setters, initializers) return "this" (instead of returning nothing - returntype="void"). Then you can do:
<cfset obj.setFirstName("Sean").setLastName("Corfield") />
Also note that omitting returntype= is *not* the same as specifying returntype="void". The latter ensures that your function returns nothing (i.e., you have no cfreturn tag or only empty cfreturn tags). If you simply omit the returntype= attribute, you can return anything and it is unchecked.
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive." -- Margaret Atwood
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
