On Friday, August 16, 2002, at 09:35 , Brook Davies wrote:
> I have a cfc which has the following argument. The problem is that if I do
> not pass it an array it throws an error that the value is not an array. 
> How
> do I make it optional to pass a value to this method?
>
> <cfargument name="descriptlistArray" type="array" required="false" 
> default="">

Why specify a default? If it isn't required, use 'isDefined()' inside the 
function.

What's happening is that the call omits the argument so CF sets it to the 
default you specified, as if the user passed that value in, and then CF 
type checks it and fails: "" is not an array.

Do this instead:

        <cfargument name="descriptlistArray" type="array" required="false"/>
        <cfif not isDefined("arguments.descriptlistArray")>
                <!--- handle omitted argument however you want, e.g.,: --->
                <cfset arguments.descriptlistArray = arrayNew(1)/>
        </cfif>

Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to