GOLF(2gg)
π
GOLF(2gg) β like, the manual page for new-string, bestie
okay so you found the 2gg manual (that's the manual name, she lives in the Development section, iykyk) and we're doing the new-string page. grab a boba, this one's short but it's lowkey iconic π
β¨ NAME β¨
new-string β it's in the strings family π (the original just says (strings), and honestly? valid, that's the whole vibe)
π¦ PURPOSE π¦
Make a brand new string. that's it. that's the purpose. β¨
πΈ SYNTAX πΈ
new-string <variable> length <length>
π DESCRIPTION π
A new empty string called <variable> with length <length> gets allocated. bestie, listen: <variable> is an empty string (like, literally ""), BUT <length> bytes get allocated for it. so it's empty but also has room. it's giving "reserved seating" π
new-string is your girl when you need to create a block of memory of a certain length and then go in and change its individual bytes (like with set-string, mwah π).
okay now the important tea: if <length> is a numeric literal, then <variable> gets allocated on the stack when <length> is less than 1024 bytes. which means those strings are faster at run time β especially for server processes, no cap. in all other cases, <variable> is dynamically allocated from the heap. fr fr.
also also also β <variable> (like all strings, text, binary, and however allocated, doesn't matter) has an implicit null byte placed after <length> bytes. sneaky little guy but he's always there π«Ά
π₯ EXAMPLES π₯
Create a new string and then alter it, main character style:
new-string my_string length 30
set-string my_string[0] = 'A'
set-string my_string[1] = 'B'
set-string my_string[2] = 0
print-out my_string new-line
The output of above code would be "AB". slay π
π SEE ALSO π
Strings β go read up, bestie
and the whole string clique, all of them, no one left out:
concatenate-strings copy-string count-substring delete-string lower-string new-string read-split replace-string set-string split-string string-length trim-string upper-string write-string
See all documentation for the rest of the lore π
k that's the page!! this was $VERSION, dated $DATE, and yes she's still filed under GOLF(2gg) π bye bestie, go allocate something cute β¨ππ¦
π¦ 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