Hi,
I have a code like this:
Str toXML() { doc := XDoc { XElem("root") { XElem("number") { XText(number.toStr), }, XElem("tags") { Tags.each |Tupla tupla, Str label| { XElem("tag"),/* { XText(label.toStr), },*/ } }, }, } buf := StrBuf() doc.write(buf.out) return buf.toStr }
and when I run fan myfile.fan, I get:
/home/xan/proves/xitz/xitz-ng/xtz.fan(120,22): Invalid use of 'it' outside of it-block ERROR: cannot compile script
(the line 120 is "XElem("tag")" line.
What's wrong.
Thanks in advance,
You're in a closure there - so your scope has changed - should be able to just assign to a local var (didn't try this):
XElem("tags") { temp := it Tags.each |tupla, label| { temp.add(XElem("tag")) } }
Thank you very much, andy.
Login or Signup to reply.
Xan Fri 9 Mar 2012
Hi,
I have a code like this:
and when I run fan myfile.fan, I get:
(the line 120 is "XElem("tag")" line.
What's wrong.
Thanks in advance,
andy Fri 9 Mar 2012
You're in a closure there - so your scope has changed - should be able to just assign to a local var (didn't try this):
Xan Fri 9 Mar 2012
Thank you very much, andy.