Pete Freitag Pete Freitag

ColdFusion Function Arguments now support Integer

coldfusion

As you may know when you create a function argument that accepts an integer in CFML you can use the type numeric which is good, but possibly not as specific as you would like.

It turns out in CF2016 and CF2018 you can now specify integer as the type! For example:

numeric function add(integer x, integer y) {
    return x+y;
}

The above will throw an exception if you try to pass something like 2.5 in to one of the integer arguments. It will work as expected if you pass an integer.

This caught me off guard because as far as I know this was never documented by Adobe. I'm not quite sure yet if it was added in the initial release of CF2016, or by some updater.

Return Types are not changed

You may have noticed that for the return type I still specified numeric, it doesn't accept integer there.

Other Types also supported

This got me wondering what other types are supported, most of the types that work for cfparam now work as an argument type. The most useful of those types is probably email:

void function setEmail(email address) {
    email = address;
}

If you have any additional info to add (such as what version that this started in), please add a comment to the ticket on cfdocs related to this.


Like this? Follow me ↯

ColdFusion Function Arguments now support Integer was first published on September 12, 2019.

If you like reading about coldfusion, cfml, cfargument, or cfparam then you might also like:

FuseGuard Web App Firewall for ColdFusion

The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.

Post a Comment