GOLF(2gg)
π 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 π¦
Arraynew-arraypurge-arrayread-arraywrite-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
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms