Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your two main options are listToArray(myList) and the java method myList.split(), as noted in previous answers and comments. There are some things to note though.</p> <ul> <li>By default ColdFusion list functions ignore empty list items.</li> <li>As of ColdFusion version 8, listToArray takes an optional third argument, includeEmptyFields, which is a boolean controlling that behavior, defaulting to false.</li> </ul> <p>For example:</p> <pre><code>listToArray("asdf,,,qwer,tyui") is ["asdf", "qwer", "tyui"] listToArray("asdf,,,qwer,tyui", ",", true) is ["asdf", "", "", "qwer", "tyui"] </code></pre> <p><strong>Re java split:</strong></p> <p>Like other java functionality that pokes up through the ColdFusion layer, this is undocumented and unsupported</p> <p>In Adobe ColdFusion 8, 9, and 10, but not in Railo, this is a syntax error:</p> <pre><code>a = "asdf,,,qwer,tyui".split(",") </code></pre> <p>But this works:</p> <pre><code>s = "asdf,,,qwer,tyui"; a = s.split(","); </code></pre> <p>As far as I can see, Adobe ColdFusion treats the result of .split() like a ColdFusion array:</p> <ul> <li>CFDumps show it as an array</li> <li>It's 1-based</li> <li>You can use arrayLen on it</li> <li>You can modify its elements in ColdFusion</li> <li>There may be other behaviors I didn't check that aren't like a CF array, but as above, it's unsupported</li> </ul> <p>In Railo:</p> <ul> <li>Debug dumps show it as Native Array (java.lang.String[])</li> <li>The other statements about its very array-like behavior are still true</li> </ul> <p>That's in contrast to real java arrays, created with createObject("java", "java.util.ArrayList").<br> <em>NOTE: That's only partly correct; see edit below.</em></p> <ul> <li>For instance, in Adobe ColdFusion, elements of a java ArrayList can't be modified directly with CFML</li> <li>In general, Railo handles java arrays more like ColdFusion ones than ACF</li> </ul> <hr> <p><strong>Edit:</strong> Thanks Leigh, I stand corrected, I should stick to what I know, which is CF way more than java.</p> <p>I was reacting to the comment saying that the result of .split() "is not a ColdFusion array, but a native Java array. You won't be able to modify it via CF", which is not the case in my experience. My attempt to clarify that by being more specific was ill-informed and unnecessary.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload