macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: ListFind and ListContains

Subject: Re: ListFind and ListContains
From: Adam Cameron
Date: Wed, 17 Sep 2008 08:42:43 +0100
Newsgroups: macromedia.coldfusion.cfml_general_discussion

> I did check the livedocs but did not understand, 

Did you read this bit:

http://livedocs.adobe.com/coldfusion/8/functions_l_09.html
{quote}
Returns

Index of the first list element that contains value, with matching case. If
not found, returns zero.
{quote}

What does that suggest that it returns, to you?


> will find the desired value inside a list, 

It returns the *index* of the match.  Its position.  So, from your list
"comments,other,active,sale", "other" is in position (index) 2.  listFind()
will return 2 in this case.


> or only returns true (gt 
> 0), as Dan's example show.

TRUE <> "gt 0".  For one thing, negative numbers also evaluate as "true"
when cast to a boolean.

CF will automatically try to cast a value in an expression to a data type
that will enable the expression to not error.  So when CF finds a numeric
in a boolean expression, it will cast it to a boolean.  All non-zero
numbers will be cast to TRUE; zero will be cast to FALSE.

Note: in future when posting, please do not suggest something simply "does
not work".  Please provide what it is that makes you think it doesn't work:
- an error message
- no error, but not what you werre expecting (and accordingly what your
expectation was, and how it wasn't met)
- any other useful information.

Saying "it didn't work" is vague and kind of taken as a given.  People
seldom post here saying "hey, just to let you know, I was working on
something and it's all fine" ;-)

-- 
Adam

<Prev in Thread] Current Thread [Next in Thread>