Actually, no. It would interpret it as null if it were enclosed in curly braces like this:
var xml:XML = <outer><inner>{null}</inner></outer>; And even then, null might be converted to its String value, "null", as the content of the element. I'd have to try it to know for sure. In the example I gave, the content of the element is a String consisting of the letters "n", "u", "l" and "l", in that order. In any case, the xmlList variable would reference a non-null XMLList object. That's easily proven by dereferencing it: trace("The length is " + xmlList.length()); That would output "The length is 1". --- On Thu, 8/13/09, Tracy Spratt <tr...@nts3rd.com> wrote: From: Tracy Spratt <tr...@nts3rd.com> Subject: RE: [flexcoders] Re: *** So you think you know ActionScript? (Read original post first) *** To: flexcoders@yahoogroups.com Date: Thursday, August 13, 2009, 3:49 PM Ah, I see something I missed at first. This example is using “literal” xml, so the null IS getting interpreted by AS as null and not as a string. I bet it would be different if you did: var xml:XML = XML(“<outer><inner> null</inner> </outer>”); Even so I am still surprised because the null should be the text node and the expression should return an XMLList with zero length. Very interesting. Tracy Spratt, Lariat Services, development services available From: flexcod...@yahoogro ups.com [mailto:flexcoders@ yahoogroups. com] On Behalf Of jaywood58 Sent: Thursday, August 13, 2009 12:48 PM To: flexcod...@yahoogro ups.com Subject: [flexcoders] Re: *** So you think you know ActionScript? (Read original post first) *** --- In flexcod...@yahoogro ups.com, "Tracy Spratt" < tracy @...> wrote: > > _____ > > From: flexcod...@yahoogro ups.com [mailto:flexcod...@yahoogro ups.com] On > Behalf Of Paul Andrews > Sent: Wednesday, August 12, 2009 9:33 PM > To: flexcod...@yahoogro ups.com > Subject: Re: [flexcoders] *** So you think you know ActionScript? (Read > original post first) *** > > > > > > Dave Glasser wrote: > > Consider this code snippet: > > > > var xml:XML = <outer><inner> null</inner> </outer>; > > var xmlList:XMLList = xml.inner; > > trace(xmlList == null); > > > > What does the trace statement output, true or false, and why? > > > > Please provide an answer without running the code (of course) and, better > yet, without consulting any documentation, or any of the other answers that > may have been posted already (if you read the list in chronological order.) > Pretend it's a job interview question and you have to give it your best shot > off the top of your head. > > > > And also, if you don't mind, don't top-post your answer, so that if > someone does read your answer before the original post, they might get a > chance to answer without having seen yours first. > > > > xmlList is set to point at somthing which isn't a list, so I think the > trace statement will not be reached. That's my 02:31AM thought.. > > > > All e4x expressions return an XMLList. It can be empty but is never a null. > Besides, the characters. "null" in a text node are just a string. "null" in > an AS comparison is a special value. The trace will display false. > Trace("xmllist. text() =="null" ); //would return true. > > > > Tracy Spratt, > > Lariat Services, development services available > Like Tracy , I thought it would return false, for the same reason -- that <inner>null< /inner> would be interpreted as a string. Was surprised when I ran the code and saw true. What's going on? It seems like the AS decoder recognizes "null" as a special case.