NAME
	foreach - the foreach statement

SYNTAX
   foreach(variable, array)
      statement

DESCRIPTION
   Execute statement once for each element in 'array', setting 'variable' to
   one element of 'array' each time around.
   A 'break' in the 'statement' will terminate the loop. A 'continue' will
   continue the execution from the beginning of the loop with the next value.

NOTE
   Expect the unexpected...

EXAMPLE
    void foo(mapping m)
    {
       mixed x;
       foreach(x, m_indices(m))
       {
          write(sprintf("%O", x) +" : " + sprintf("%O", m[x]) + "\n");
       }
    }

    Will print out the contents of the mapping passed to function foo,
    one index : value on each line.
    "foo(([1:2,3:4,5:6]));" would give the following output:
    1 : 2
    3 : 4
    5 : 6

Help topics available:
C_vs_LPC Lesson1 README arrays block
class3 class4 class1 class2 control_structures
for foreach function inheritance keywords
learn_lpc/ lfuns lpc_standardized mappings operators
preprocessor profezzorn_has_the_word switch things_not_to_do types
virtual while

[START|BACK ]




[ NannyMuds main page | FAQ | Contact us ]

You are guest number 138 since November 2019.
This file was last modified: June 2000.