Inserts an element at the beginning of a list.
listPrepend(someList, value [, delimiters, includeEmptyFields])
→ returns string
someList.listPrepend( value [, delimiters, includeEmptyFields])
,
false
true
false
CF 11+ Lucee 4.5+
seinfeldList = "Close Talker,Soup Nazi";
seinfeldList = seinfeldList.listPrepend("Puffy Shirt");
writeOutput(seinfeldList);
Expected Result: "Puffy Shirt,Close Talker,Soup Nazi"
someList = "1-2-3-4";
someList = listPrepend(someList,"0","-");
writeOutput(someList);
Expected Result: "0-1-2-3-4"
CF 2018+
someList = "Feb,Mar,Apr";
someList = listPrepend(someList, ",,Jan", ",", true);
writeOutput(someList);
Expected Result: ",,Jan,Feb,Mar,Apr"
CF 2018+
someList = "Feb,Mar,Apr";
someList = listPrepend(someList, ",,Jan,,", ",", false);
writeOutput(someList);
Expected Result: "Jan,Feb,Mar,Apr"
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.