Barney,
I'm curious - why do you prefer structKeyExists() vs. setting
default values?
Walt
-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 30, 2004 6:26 PM
To: CF-Talk
Subject: Re: CFC required arguments
If you use positional parameters, only parameters at the end can be
left off. However, you can use named parameters without using
CFINVOKE:
<cfset o.method(name=url.name, age=url.age, ...) />
I generally prefer to not specify a default for my option arguments,
and then use structKeyExists() against the 'arguments' struct to check
if they were passed. Since we don't have method overloading in CF,
optional parameters (and their associated conditionals) are a
necessary evil.
cheers,
barneyb
On Wed, 1 Dec 2004 10:20:27 +1100, Paul Wilson <[EMAIL PROTECTED]> wrote:
> I'm using createObject to invoke a CFC and one of the methods in the CFC
> takes a number of arguments, all numeric but not all required. In the
> CFC I have some conditional statements that do various things based on
> the arguments passed in.
>
> <cfif arguments.arg neq "">do this</cfif>
>
> Firstly is it a good idea to do this in a CFC? And secondly, how can I
> pass is the only the arguments required .e.g.
>
> <cfset result = obj.testmethod(0,1, ,10)
>
> The third argument is not required but this will throw an error. This
> situation doesn't arise when you use cfinvoke as you can simply miss out
> the cfinvokeargument tag.
>
> Thanks
>
--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/blog/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185797
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54