Posted to tcl by egavilan at Fri Apr 26 00:52:01 GMT 2024view raw
- proc ::tcl::dict::pop {var args} {
- upvar 1 $var lvar
- ::set value [get $lvar {*}$args]
- unset lvar {*}$args
- return $value
- }
- namespace ensemble configure ::dict -map [dict merge \
- [namespace ensemble configure ::dict -map] \
- [dict create pop ::tcl::dict::pop]]
- # usage:
- # % set var {a 1 b 2 c 3}
- # a 1 b 2 c 3
- # % dict pop var a
- # 1
- # % set var
- # b 2 c 3
- # % dict pop var c
- # 3
- # % set var
- # b 2