Today I ran across two errors that I've seen many CF newbiews do in the past - so I thought I'd share them with you so you can watch out for them in your own code.

The first one involves lists. ColdFusion has many list functions. One of the common things people want to do is find an item in a list. However, many people accidently use the ListContains (or ListContainsNoCase) functions. This function will search each list item and see if it contains the string your are looking for. So, if your list is:


and you want to find ray in the list, listContains will return 2, which means the second item contains the string ray. If you really want to find the item that is ray and is only ray, use ListFind or ListFindNoCase. (Did you know that there isn't an arrayFind()? You can find one at!)

The second error was more subtle. In almost all cases, when you do <cfset a= b>, you are creating a copy of b in a variable called a. However, if b is a structure, you have made a pointer instead. If you modify a, you will modify b as well. This can lead to headaches trying to figure out why b isn't working correctly. To remedy this, use duplicate instead. Do NOT use structCopy. structCopy will still return a variable with pointers if the structure contains structures itself.