Well your correct in that createObject returns "this" ( ie the instance ) but it dosn't run init(). Try put a writeOutput or dump in the init method then running it both ways on that test page, new Test(); will display the output but create object wont.
I just checked my cf9 server and it's 9.01 just incase ( grr all those updates but thats another story ). Paul. On Mon, Jul 18, 2011 at 9:51 PM, Andrew Scott <[email protected]>wrote: > Maybe it was a CF9.01 change then!! > > But try this page > > http://andyscott.id.au/andrewscott/ > > and here is the code. > > <cfscript> > writeOutput('Using CreateObject..'); > test = CreateObject("component","test"); > writeDump(test); > > writeOutput('Using new operand..'); > test1 = new test(); > writeDump(test1); > > </cfscript> > > Notice I also do not use the return, nor do I have the init() method > either. Silly thing is I was just quoting what you said to someone else, and > they didn't know what I was talking about. So when I created this test page > I was like WTF... > > > On Mon, Jul 18, 2011 at 9:33 PM, Paul Kukiel <[email protected]> wrote: > >> Interesting as the docs indicate otherwise? >> >> Note: Only the new operator automatically invokes the initmethod or init >> function. >> The new operator returns the value returned by init or initmethod and if >> the return is void it returns the instance of the CFC. The cfobject tags >> and the CreateObject function do not invoke the function and you must >> explicitly call any custom initialization code >> >> >> http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS61C07B60-3D65-4d71-8F2A-8411D8010E60.html >> >> And I tried this and it dosn't call init() without explicitly calling >> init(). I can only assume they did this for backwards compatibility. >> >> Paul >> >> * >> * >> > -- > You received this message because you are subscribed to the Google Groups > "cfaussie" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/cfaussie?hl=en. > -- Paul Kukiel -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.
