Re: [Phix] Language Feature Request: For Each

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

How about a For...Each...End For?

I was thinking

for i, string key in {"one","two","three"} do 
for i, id in {2,4,6} do 
for i, object key in {"Hello",3,{1,2,3}} do 
for i, string key in all_keys do 

Why "for i"? (It seems redundant.)

Should simply be:

for string key in {"one","two","three"} do 
for integer id in {2,4,6} do 
for object key in {"Hello",3,{1,2,3}} do 
for string key in all_keys do 

"key" takes on the value of, not the pointer to, the element in the sequence it is iterating, so the iterable sequence never gets changed in this.

Javascript's forEach() is definitely interesting, but is a method on a class (it seems), so not analogous to Phix's version (it seems).

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

Search



Quick Links

User menu

Not signed in.

Misc Menu