struct::map(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

struct::map β€” managing key/value maps, bestie πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

package require struct::map ?1?

::struct::map mapName

mapName method ?arg arg ...?

mapName get

mapName names

mapName set name ?value?

mapName unset ?pattern...?

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so, struct::map hands you a snit class whose instances manage a key/value map. And what even is that, you ask? It's literally an object wrapper around Tcl arrays. That's the whole vibe. No cap. 🫢


πŸ‘‘ API πŸ‘‘

The main command is the one that builds your maps, and it's giving main character energy:

  • ::struct::map mapName β€” Creates a brand new, empty map, and that map gets an associated global Tcl command whose name is mapName. You can use that command to invoke all kinds of operations on the map. Its general form is:
mapName method ?arg arg ...?

method and the args decide the exact behavior of the command. πŸ’–

Oh and btw β€” if mapName is specified as %AUTO%, the package itself generates a unique name for you. Slay. ✨ The result of the command is the fully-qualified name of the instance command.


🌸 The commands you can throw at a map object 🌸

  • mapName get β€” Returns the entire map as a Tcl dictionary. The whole thing. Every last crumb. πŸ’œ
  • mapName names β€” Returns the list of all keys known to the map, in arbitrary order. So don't come for me about ordering, it did not promise you anything. πŸ™ˆ
  • mapName set name ?value? β€” Sets key name to the specified value, if the value is specified. Returns the value for the key. Throws an error if the key is not known. 😭
  • mapName unset ?pattern...? β€” Removes all keys matching at least one of the glob patterns from the map. If you don't specify a pattern, all keys get removed β€” in other words, the default pattern is *. The result of the command is the empty string. Bye bye data 🫢

πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

Not to be dramatic but this document, and the package it describes, will undoubtedly contain bugs and other problems. It's giving humble, it's giving honest. πŸ™ˆ

  • Please report such in the category struct :: list of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist.
  • Please also report any ideas for enhancements you may have for either the package and/or the documentation. We love a glow-up suggestion ✨

When proposing code changes, please provide unified diffs, i.e. the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button</c> in the secondary navigation bar. iykyk πŸ’…

okay that's the whole page, bestie!! πŸŽ€ This lil legend came from tcllib, version 1, and it's the struct::map(3tcl) page β€” go forth and map your keys and values, you absolute icon πŸ‘‘πŸ’–πŸ¦‹

πŸ“¦ where this page comes from