ColdFusion Tech

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.

ColdFusion API Manager at CFSummit 2018
Language improvements in ColdFusion 2018 at Adobe Immerse '18

By Immanuel Noel

A techie at heart. Works with Adobe at Bangalore, India. Currently do DevOps. Been a part of the ColdFusion Engineering, Flash Runtime Engineering, Flash Builder Engineering teams in the past. Was a Flash Platform Evangelist, evangelizing the Adobe Flex platform. Spoke at numerous ColdFusion / Flash and Flex tech conferences. This blog is a collection of some of my strides with technology.

More on me on the home page

Leave a Reply

Your email address will not be published. Required fields are marked *