arrays - Is there a function similar to ArrayFind from ColdFusion 9 in ColdFusion 8? -


i talking fellow programmer @ work , use coldfusion. telling me value in array have whole loop? true there no function in coldfusion 8 value in array?

arrayfind() doesn't exist in coldfusion 8. however, don't need loop. there 2 ways:

take advantage of fact coldfusion arrays implement interface java.util.list:

<cfset valuetofind = 1> <cfset array = [1,2,3]> <!--- add 1 because cf 1 based vs. java 0 based arrays ---> <cfset position = array.indexof(valuetofind) + 1>  

use list operations:

<cfset valuetofind = 1> <cfset array = [1,2,3]> <cfset position = listfind(arraytolist(array), valuetofind)> 

the first (java list) method faster.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -