ColdFusion Function Arguments now support Integer

September 12, 2019
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 ↯


You might also like:

This entry was:

Post a Comment




  






Foundeo Inc.