Enhanced Support For New Operator

July 12, 2018
Newbie 4 posts
Followers: 1 people
2

Enhanced Support For New Operator

Newbie 4 posts
Followers: 1 people
July 12, 2018

In the 2018 release of ColdFusion, there is a handy way to create objects in ColdFusion.

The snippet below illustrates how you can use the new operator to create different type of objects.

 

//ColdFusion Component

obj = new component(“path.to.cfc”)

obj.init()

 

// Java

obj = new java(“java.class”)

obj.init()

 

// WebService

obj = new webservice(“http://webservice?wsdl”, {“webservice”: “parameters”})

 

Similarly, you can use the new operator to create com, CORBA, and .NET objects as well.

Comments (2)
2018-08-16 09:44:36
2018-08-16 09:44:36

Hi Adobe,

+1 to an answer to Brad’s question. What happened to the discussed/preferred syntaxes that no longer work?

Thanks!,
-Aaron

Like
2018-07-12 19:56:19
2018-07-12 19:56:19

Just to be clear, this syntax calls init for you:
obj = new path.to.cfc();

but this one doesn’t:
obj = new component(“path.to.cfc”);

What happened to the other syntax I saw during the prerelease– did this go away?

new java:java.lang.String();

Like
Add your comment