-
-
Notifications
You must be signed in to change notification settings - Fork 15
OSL ‐ Arrays
DanimalsTCGYT edited this page Aug 4, 2024
·
10 revisions
Arrays in OSL are defined by []
and can contain elements of any length and any data type, allowing for flexibility in data structure.
Example array:
["Hello", "Wow", 100, {"huh": 10}]
Indexes in OSL arrays start at "1".
To define an array, use the following syntax:
arrayName = ["element1", "element2", ...]
Example:
myArray = ["test", "data"]
-
.append("string")
:- Adds a new element (in this case, a string) to the end of an array.
-
Example:
Results in
myArray = ["hi"] myArray.append("goodbye")
["hi", "goodbye"]
.
-
.index("string")
:- Finds the index of a specific element (string) in an array.
-
Example:
myArray = ["hi", "goodbye"] index = myArray.index("hi")
index
now contains1
.
-
.delete(int)
:- Removes an element at a specific index from an array.
-
Example:
Results in
myArray = ["hi", "goodbye"] myArray.delete(1)
["goodbye"]
.
-
.item(int)
or.[int]
or[int]
:- Retrieves the item at a specific index in the array.
-
Example:
myArray = ["hi", "goodbye"] item = myArray.item(1) item = myArray.[1] item = myArray[1]
item
now contains"hi"
.
-
.join("string")
:- Combines all elements of an array into a single string, separated by the specified separator.
-
Example:
myArray = ["hello", "how are you"] result = myArray.join(", ")
result
now contains"hello, how are you"
.
-
.split("string")
:- Splits a string into an array of substrings, separated by the specified separator.
-
Example:
myString = "hello, how are you" resultArray = myString.split(", ")
resultArray
now contains["hello", "how are you"]
.
-
.insert(position, "string")
:- Inserts a new element (string) at a specified position in the array.
-
Example:
Results in
myArray = ["apple", "banana", "cherry"] myArray = myArray.insert(2, "orange")
["apple", "orange", "banana", "cherry"]
. The string "orange" is inserted at position 2, shifting the subsequent elements to make room.
originOS is a web desktop gui with a self contained file system, programming languages, internet system and a whole lot of stuff an os should be able to do Use originOS here