Go to the first, previous, next, last section, table of contents.

WITH Statement

The WITH statement binds identifiers id to the value of expressions expr. Expressions are evaluated only once at the beginning of the statement, and the identifiers are visible only within the scope of the WITH statement. If expr is something you can write to, such as a variable, id becomes an alias for it, so modifying id also modifies the variable to which it is bound.


Example

The following example prints the contents of a file "data.txt" on standard output. Note that IO.OpenRead is only called once.


Go to the first, previous, next, last section, table of contents.