diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2016-12-21 22:46:09 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2016-12-21 22:46:09 (GMT) |
commit | 768f87f613cc9789fcf8073018fa02178c8c91df (patch) | |
tree | ec633f5608ef498bee52a5f42c12c49493ec8bf8 /tcl8.6/doc/lassign.n | |
parent | 07e464099b99459d0a37757771791598ef3395d9 (diff) | |
parent | 05fa4c89f20e9769db0e6c0b429cef2590771ace (diff) | |
download | blt-768f87f613cc9789fcf8073018fa02178c8c91df.zip blt-768f87f613cc9789fcf8073018fa02178c8c91df.tar.gz blt-768f87f613cc9789fcf8073018fa02178c8c91df.tar.bz2 |
Merge commit '05fa4c89f20e9769db0e6c0b429cef2590771ace' as 'tcl8.6'
Diffstat (limited to 'tcl8.6/doc/lassign.n')
-rw-r--r-- | tcl8.6/doc/lassign.n | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tcl8.6/doc/lassign.n b/tcl8.6/doc/lassign.n new file mode 100644 index 0000000..e250729 --- /dev/null +++ b/tcl8.6/doc/lassign.n @@ -0,0 +1,60 @@ +'\" +'\" Copyright (c) 1992-1999 Karl Lehenbauer & Mark Diekhans +'\" Copyright (c) 2004 Donal K. Fellows +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +.TH lassign n 8.5 Tcl "Tcl Built-In Commands" +.so man.macros +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +lassign \- Assign list elements to variables +.SH SYNOPSIS +\fBlassign \fIlist \fR?\fIvarName ...\fR? +.BE +.SH DESCRIPTION +.PP +This command treats the value \fIlist\fR as a list and assigns +successive elements from that list to the variables given by the +\fIvarName\fR arguments in order. If there are more variable names +than list elements, the remaining variables are set to the empty +string. If there are more list elements than variables, a list of +unassigned elements is returned. +.SH EXAMPLES +.PP +An illustration of how multiple assignment works, and what happens +when there are either too few or too many elements. +.PP +.CS +\fBlassign\fR {a b c} x y z ;# Empty return +puts $x ;# Prints "a" +puts $y ;# Prints "b" +puts $z ;# Prints "c" + +\fBlassign\fR {d e} x y z ;# Empty return +puts $x ;# Prints "d" +puts $y ;# Prints "e" +puts $z ;# Prints "" + +\fBlassign\fR {f g h i} x y ;# Returns "h i" +puts $x ;# Prints "f" +puts $y ;# Prints "g" +.CE +.PP +The \fBlassign\fR command has other uses. It can be used to create +the analogue of the +.QW shift +command in many shell languages like this: +.PP +.CS +set ::argv [\fBlassign\fR $::argv argumentToReadOff] +.CE +.SH "SEE ALSO" +lindex(n), list(n), lrange(n), lset(n), set(n) +.SH KEYWORDS +assign, element, list, multiple, set, variable +'\"Local Variables: +'\"mode: nroff +'\"End: |