Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Variable not avilable out of a foreach

From: edoconnor:gm:ail at: 11-Dec-2007 13:20

With rebol, one often hears the (adapted) Einstein quote, "Make things as simple as possible, but no simpler." The act of explaining something can make it seem more complicated than it is. I think this is the case with foreach and contexts. foreach LINE database [get_data] I think of LINE as a local function variable, owned by foreach. You can use the variable only within the foreach expression. To use it outside the scope of foreach, you need to assign the value of LINE to a global variable. Anton's comments for techniques #1 and #2 provide the common ways of doing this. Ed