append(n)
πΈ NAME πΈ
append β appending to a variable, bestie, it's literally what it does π
β¨ SYNOPSIS β¨
append varName ?value value value ...?
π DESCRIPTION π
Okay so here's the tea, gorgeous: append takes all of those value arguments and tacks them onto the current value of the variable called varName. That's it. That's the whole vibe. π
And if varName doesn't exist yet? No worries, no cap β it just gets created, and its brand-new value is the concatenation of all the value arguments. Instant main character energy. β¨
Now, plot twist for the array girlies: if varName points at an element that doesn't exist, of an array that has a default value set, then the concatenation of that default value and all the value arguments is what gets stored in the array element. Slay. π¦
The result of this command β like, what it actually hands back to you β is the new value that got stored in the variable varName. So you always know what you're working with. π
Real talk though, why is this iconic? Because it's the efficient way to build up long variables incrementally. The way that append a $b is so much more efficient than set a $a$b when $a is longβ¦ it's giving optimized. π₯
π EXAMPLE π
Building a string of comma-separated numbers piecemeal using a loop, because sometimes you gotta assemble the fit one accessory at a time:
set var 0
for {set i 1} {$i<=10} {incr i} {
append var "," $i
}
puts $var
# Prints 0,1,2,3,4,5,6,7,8,9,10
Look at that output. 0,1,2,3,4,5,6,7,8,9,10. Ate. ππ
π SEE ALSO π
π KEYWORDS π
append, variable
okay bestie, that's the whole page β go forth and concatenate responsibly π«Άβ¨
this little love letter to append(n) comes to you straight from the Tcl built-in commands, manual page append(n) β written with so much affection, and honestly it's giving timeless because it's still exactly this good π
π§
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- Copyright (c) 1993 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms