On Jan 21, 2004, at 3:24 PM, Ben Curtis wrote:
Is it even possible in any other circumstance to create such a structure/array with undefined elements? I had assumed no, and coded many a function with that assumption.

Yup. Very easy. Call any Java method in a way that returns a null pointer and assign it to a struct element or array element - CF will treat it as an undefined value.


// NullValue.java:
public class NullValue {
        public Object getNull() { return null; }
}

<!--- UseNull.cfm: --->
<cfset nullvalue = createObject("java","NullValue") />
<cfset arr = arrayNew(1) />
<cfset arr[1] = "one" />
<cfset arr[2] = "two" />
<cfset arr[3] = "three" />
<cfset arr[2] = nullvalue.getNull() />
<cfif not isDefined("arr[2]")>
        arr[2] is not defined!
</cfif>
<cfset str = structNew() />
<cfset str.one = 1 />
<cfset str.two = 2 />
<cfset str.three = 3 />
<cfset str.two = nullvalue.getNull() />
<cfif not isDefined("str.two")>
        str.two is not defined!
</cfif>

(untested code but I think it'll show what I mean)

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

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

----------------------------------------------------------
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 www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to