Re: [Phix] Language Feature Request: For Each

new topic     » goto parent     » topic index » view thread      » older message » newer message
_tom said...

sample usage

  • simulate the existing ''for'' loop
each {i} in  {"one","two","three"} do 
   ? i 
end each 

1 
2 
3 

I guess it's really just syntactic sugar.

sequence s = {1,2,3,4,5} 
integer i = length(s) 
for x=1 to i do 
  ?s[x] 
end for 
 
-- vs 
 
sequence s = {1,2,3,4,5} 
each i in s do 
  ?i 
end each 
 
-- each without specifying iterating variable type is default object 
sequence s = {1,2,3,4,5} 
each integer i in s do 
  ?i 
end each 
 

Each one produces the exact same output.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu