0

This works

<cfif ArrayContains(["bridge","ccf"], getSection())>

This does not

<cfif ["bridge","ccf"].Contains(getSection())>

Error message

Column 7

Detail ColdFusion was looking at the following text:

[

The CFML compiler was processing:

  • A cfif tag beginning on line 15, column 2.
KnownColumn 2 KnownLine 15 KnownText cfif Line 15 Message Invalid CFML construct found on line 15 at column 7.
Snippet

Did I convert this right, of is this a limitation of Adobe's implementation?

Leigh
  • 28,765
  • 10
  • 55
  • 103
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • `ArrayContains()` works fine – James A Mohler Sep 02 '15 at 16:16
  • (Edit) Then why do you need ["bridge","ccf"].Contains(getSection())? :) I suspect you will have to use an intermediary variable. Though, I would not recommend using .Contains() as it is a java method, meaning it is case and type sensitive. Side note, you are missing a closing `>` in the CFIF. Not sure if that is a typo. – Leigh Sep 02 '15 at 16:18
  • It is just a code fragment. The rest of the code is OK. I am trying to convert my code to use member functions. I am thinking that ACF does not support a literal on a member function. – James A Mohler Sep 02 '15 at 16:23
  • (Edit) Most likely not. You will need an intermediary variable. *it is case and type sensitive.* Never mind. Bad testing on my part. I forgot ArrayContains *is* case sensitive too. – Leigh Sep 02 '15 at 16:30

1 Answers1

2

ColdFusion does not support calling methods on a literal, no.

Ref: Member functions cannot be called on literals, which says:

This should work:

"lowercase".ucase()

It currently doesn't.

Community
  • 1
  • 1
Adam Cameron
  • 29,677
  • 4
  • 37
  • 78
  • Coincidentally, guess what comes up as the first search result for "ColdFusion Array Member function on a literal"? ;-) http://blog.adamcameron.me/2014/02/coldfusion-11-member-functions.html – Leigh Sep 02 '15 at 16:38