GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ‘‘ GOLF(2gg) β€” read-array πŸ’…

okay bestie, welcome to the GOLF(2gg) manual, Development section, and we are literally about to pop off about one little command. sit down, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

read-array - (array)


🎯 PURPOSE 🎯

Get data from an array. that's it. that's the whole vibe. slay. 🌈


πŸ“œ SYNTAX πŸ“œ

read-array <array> \
    key <key> \
    value <value> \
    [ delete [ <delete> ] ]

πŸ’– DESCRIPTION πŸ’–

so, read-array will obtain an element from <array> β€” and bestie, that array has to have been created with new-array first, no cap. the element you get back is <value> (that's the "value" clause, obviously πŸ’…), and it's picked based on a number <key> (that's the "key" clause). <key> is a number from 0 up to β€” but not including β€” the currently allocated array size. periodt.

the type of <value> is decided when <array> gets created (peep the "type" clause for that), and it can be a string, a number or a boolean. iconic trio, honestly. 🫢


you can also yeet an element right out of the array using the "delete" clause β€” but here's the thing, <value> is still obtained even though it's no longer in the array. the array element gets deleted if:

  • the "delete" clause is used without the boolean variable <delete>, or
  • <delete> evaluates to true.

and what does "deleting" actually mean?? it means if it's a string store it'd be set to an empty string, if it's a number it'd be set to 0, and if it's a boolean it'd be set to false. so it's not gone-gone, it's just... reset. lowkey feral but okay. πŸ’€


heads up bestie: an array may be allocated beyond the highest index of an element that's actually been written to it. so if you read from elements that have never been written to? you'll get an empty string, a number 0, or a boolean false value β€” depending on the type of the array. no surprises, no drama. 🧚

🌸 EXAMPLES 🌸

okay so in this example: a new array is created, a value is written to it, then the value is obtained and the element is deleted. and yes, the return status gets checked too, because we're responsible queens here. πŸ‘‘

// Create new array
new-array arr type string

// Write to array
write-array arr key 500 value "some data"

// Read from array
read-array arr key 500 value res status st delete
@Deleted value is <<print-out res>>

πŸ¦‹ SEE ALSO πŸ¦‹

  • Array
  • new-array
  • purge-array
  • read-array
  • write-array
  • See all documentation

and that's the whole page, bestie, you ate that. πŸ’…βœ¨

this gorgeous little doc dropped as version $VERSION on $DATE β€” yeah, we're GOLF(2gg) and we're the moment. πŸŽ€ no cap, fr fr. 🫢

πŸ“¦ where this page comes from