ColdFusion 2018 – Improvements on Arrays and Strings

ColdFusion 2018 includes a host of new enhancements on Language. Language improvements have been considered based on use-cases that make more sense in today’s world, and while also taking into consideration all the bugs and enhancements logged by the community.

Significant enhancements are Null Support – with ColdFusion now Null aware, working alongside other technologies such as JavaScript has become a whole lot easier. ColdFusion now preserves the date-type of your variables, and does away with the “guessing”. What this means is, ColdFusion does a better job primarily while interfacing with databases and while serializing / deserializing data.

ColdFusion also includes enhancements on purely language constructs as well. We will be looking at Arrays and Strings here.


Typed Arrays:
Datatypes can now be defined for Arrays. Supported Datatypes are String, Numeric, Boolean, Date, Array, Struct, Query, Components, Binary and Function. The scope of typed arrays can be extended by defining the type as a custom component as well. The syntax for typed array’s is defined below,

arr = arrayNew['String'](1);


Negative Indices:
Array’s can now be queried not just with indexes, but also with negative indexes. A negative index, -1, would fetch the last element of the array, a index of -2, would fetch the last but one element of the array, and so on and so forth. Syntax for negative indices is the same as that for querying array’s with indices.



Array Slices:

Array’s can also be queried with the new slices syntax. The syntax allows you to specify the start index, end index, and a step. The step refers to the interval at which items in the array will be returned. For example, for the syntax displayed below, all alternate items in the array starting with the index 1, upto the last but one element will be returned. Alternate, since the step is specified as 2.




String Literals:
With String literals, you can now invoke string member function on the literals itself. This could be useful for authoring unit-tests, for example. Strings do not need to be stored in a variable before manipulations.

" The quick brown fox jumps over the lazy dog ".trim().len()


For more information on Array’s and String’s refer to the post on the ColdFusion Community Portal.

Language improvements in ColdFusion 2018 at Adobe Immerse '18

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>