1lassign(n)                   Tcl Built-In Commands                  lassign(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       lassign - Assign list elements to variables
9

SYNOPSIS

11       lassign list ?varName ...?
12______________________________________________________________________________
13

DESCRIPTION

15       This  command  treats  the  value list as a list and assigns successive
16       elements from that list to the variables given by the varName arguments
17       in  order.   If  there  are more variable names than list elements, the
18       remaining variables are set to the empty string.   If  there  are  more
19       list  elements  than  variables,  a  list  of  unassigned  elements  is
20       returned.
21

EXAMPLES

23       An illustration of how multiple assignment works, and what happens when
24       there are either too few or too many elements.
25
26              lassign {a b c} x y z       ;# Empty return
27              puts $x                     ;# Prints "a"
28              puts $y                     ;# Prints "b"
29              puts $z                     ;# Prints "c"
30
31              lassign {d e} x y z         ;# Empty return
32              puts $x                     ;# Prints "d"
33              puts $y                     ;# Prints "e"
34              puts $z                     ;# Prints ""
35
36              lassign {f g h i} x y       ;# Returns "h i"
37              puts $x                     ;# Prints "f"
38              puts $y                     ;# Prints "g"
39
40       The  lassign command has other uses.  It can be used to create the ana‐
41       logue of the “shift” command in many shell languages like this:
42
43              set ::argv [lassign $::argv argumentToReadOff]
44

SEE ALSO

46       lindex(n), list(n), lrange(n), lset(n), set(n)
47

KEYWORDS

49       assign, element, list, multiple, set, variable
50
51
52
53Tcl                                   8.5                           lassign(n)
Impressum