It would depend on a couple of things...... (but this is just a general principal - not a comment on CFMX actual behaviour)
1. IF an empty string was an invalid input (i.e. you just should NOT be having an empty string at that point) - you should check for it in the function and throw the error 2. IF the code that uses a return value expects no empty values (e.g. all the elements of the array should be a number) - you should check for the empty value and throw the error. 3. IF you WANT empty values - you should do nothing. (it really depends on what you are attempting to achieve) Of course, we all know what the ACTUAL behaviour of CFMX is...... LISTS ignore "blank" entries. So, if you want blank entries you have to make up some pseudo blank entry in the list (like "--null--") so that it gets treated like a "real" element. Then you have to strip them out or programmatically ignore them in your code. SO.... back to your original question of "should empty strings __always__ be allowed".... The answer is: "It depends on the specific context and logic of what you are writing. Sometimes YES, sometimes NO". Regards, Gary On Fri, 3 Dec 2004 19:51:40 -0000, Kerry <[EMAIL PROTECTED]> wrote: > Personally, I would return an empty array, with one empty element, the > rationale being: > > if you passed it: 12345qwerty > you would get back exactly what you passed in, but as the first element in > an array. > > so if you passed it: [empty string] > > shouldnt the behaviour be the same? (not that cold fusion agrees with this > rationale...) > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Dawson, Michael > Sent: 03 December 2004 19:02 > To: [EMAIL PROTECTED] > Subject: [CFCDev] Check for Empty Strings in Required String Arguments > > How many of you check for empty strings in required string-type > arguments? > > For example, I have this function: > > <cffunction name="mySplit" return="array" ...> > <cfargument name="myList" type="string" required="yes"> > > <cfreturn listToArray(arguments.myList, ",")> > </cffunction> > > Then, I call the function like this: > > <cfset result = mySplit("")> > > Do you let this function return an empty array or do you throw an error? > What is the general consensus? Should empty strings _always_ be allowed > since they tend to be an exception to required arguments? > > Thanks > M!ke > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > [EMAIL PROTECTED] > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > [EMAIL PROTECTED] > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at [EMAIL PROTECTED]
