From 0f2ee58694fc9d5162eeaaab9299b06321fd6370 Mon Sep 17 00:00:00 2001 From: FeudalDiana <104153251+FeudalDiana@users.noreply.github.com> Date: Sun, 5 Jan 2025 05:07:15 +0000 Subject: [PATCH 1/3] Update names to match convention --- content/en-us/luau/queues.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/content/en-us/luau/queues.md b/content/en-us/luau/queues.md index 1e95b66b6..0121a0582 100644 --- a/content/en-us/luau/queues.md +++ b/content/en-us/luau/queues.md @@ -58,20 +58,20 @@ function Queue.new(): Queue end -- Check if the queue is empty -function Queue.IsEmpty(self: Queue) +function Queue.isEmpty(self: Queue) return self._first > self._last end -- Add a value to the queue -function Queue.Enqueue(self: Queue, value: T) +function Queue.enqueue(self: Queue, value: T) local last = self._last + 1 self._last = last self._queue[last] = value end -- Remove a value from the queue -function Queue.Dequeue(self: Queue): T - if self:IsEmpty() then +function Queue.dequeue(self: Queue): T + if self:isEmpty() then error("Cannot dequeue from empty queue") end @@ -96,27 +96,27 @@ local Queue = require(ReplicatedStorage:WaitForChild("Queue")) local myQueue = Queue.new() -- Add some values to the queue -myQueue:Enqueue(5) -myQueue:Enqueue(10) -myQueue:Enqueue(15) +myQueue:enqueue(5) +myQueue:enqueue(10) +myQueue:enqueue(15) -- myQueue = { 5, 10, 15 } -- Remove one value from the queue -local first = myQueue:Dequeue() +local first = myQueue:dequeue() print("The first value added to the queue was", first) -- myQueue = { 10, 15 } -- Add more values to the queue -myQueue:Enqueue(20) -myQueue:Enqueue(25) -myQueue:Enqueue(30) +myQueue:enqueue(20) +myQueue:enqueue(25) +myQueue:enqueue(30) -- myQueue = { 10, 15, 20, 25, 30 } -- Remove another value from the queue -local second = myQueue:Dequeue() +local second = myQueue:dequeue() print("The second value added to the queue was", second) -- myQueue = { 15, 20, 25, 30 } From ae1074db6a87e8b4cf809f4cecc20827fbda1eba Mon Sep 17 00:00:00 2001 From: FeudalDiana <104153251+FeudalDiana@users.noreply.github.com> Date: Sun, 5 Jan 2025 05:17:01 +0000 Subject: [PATCH 2/3] Update names to match convention --- content/en-us/luau/stacks.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/content/en-us/luau/stacks.md b/content/en-us/luau/stacks.md index 99b582a62..ddc2f75f1 100644 --- a/content/en-us/luau/stacks.md +++ b/content/en-us/luau/stacks.md @@ -26,18 +26,18 @@ function Stack.new() end -- Check if the stack is empty -function Stack:IsEmpty() +function Stack:isEmpty() return #self._stack == 0 end -- Put a new value onto the stack -function Stack:Push(value) +function Stack:push(value) table.insert(self._stack, value) end -- Take a value off the stack -function Stack:Pop() - if self:IsEmpty() then +function Stack:pop() + if self:isEmpty() then return nil end @@ -57,21 +57,21 @@ local s = Stack.new() -- Change the stack Resulting stack Output -s:Push(1) -- {1} +s:push(1) -- {1} -s:Push(5) -- {1, 5} +s:push(5) -- {1, 5} -s:Push(10) -- {1, 5, 10} +s:push(10) -- {1, 5, 10} -print(s:Pop()) -- {1, 5} 10 +print(s:pop()) -- {1, 5} 10 -print(s:Pop()) -- {1} 5 +print(s:pop()) -- {1} 5 -s:Push(20) -- {1, 20} +s:push(20) -- {1, 20} -print(s:Pop()) -- {1} 20 +print(s:pop()) -- {1} 20 -print(s:Pop()) -- {} 1 +print(s:pop()) -- {} 1 ``` From 5416d3dfe6f20c0f33a59751618e43ce44db409d Mon Sep 17 00:00:00 2001 From: FeudalDiana <104153251+FeudalDiana@users.noreply.github.com> Date: Sun, 5 Jan 2025 05:22:41 +0000 Subject: [PATCH 3/3] Update variables to match convention --- content/en-us/luau/tables.md | 60 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/content/en-us/luau/tables.md b/content/en-us/luau/tables.md index 6acd31b5c..040d6c424 100644 --- a/content/en-us/luau/tables.md +++ b/content/en-us/luau/tables.md @@ -141,9 +141,9 @@ To create a dictionary table, define each **key** followed by `=` and the **valu ```lua local testDictionary = { - FruitName = "Lemon", - FruitColor = "Yellow", - Sour = true + fruitName = "Lemon", + fruitColor = "Yellow", + sour = true } ``` @@ -153,7 +153,7 @@ The keys for dictionaries can be numbers, strings, and objects. For example, a k local part = Instance.new("Part") local testDictionary = { - PartType = "Block", + partType = "Block", [part] = true } ``` @@ -166,11 +166,11 @@ To read from a dictionary, add a pair of brackets after its reference and specif local part = Instance.new("Part") local testDictionary = { - PartType = "Block", + partType = "Block", [part] = true } -- Include quotes for string keys -print(testDictionary["PartType"]) -- Block +print(testDictionary["partType"]) -- Block -- Omit quotes for non-string keys print(testDictionary[part]) -- true ``` @@ -181,19 +181,19 @@ To define or rewrite the value of a new or existing dictionary key, declare the ```lua local testDictionary = { - FruitName = "Lemon", - Sour = true + fruitName = "Lemon", + sour = true } -- Change value of existing keys -testDictionary["FruitName"] = "Cherry" -testDictionary["Sour"] = false +testDictionary["fruitName"] = "Cherry" +testDictionary["sour"] = false -- Insert new key-value pair testDictionary["FruitCount"] = 10 -print(testDictionary["FruitName"]) -- Cherry -print(testDictionary["Sour"]) -- false +print(testDictionary["fruitName"]) -- Cherry +print(testDictionary["sour"]) -- false print(testDictionary["FruitCount"]) -- 10 ``` @@ -203,9 +203,9 @@ To iterate over a dictionary, use the global `pairs()` function in a `for` loop: ```lua local testDictionary = { - FruitName = "Lemon", - FruitColor = "Yellow", - Sour = true + fruitName = "Lemon", + fruitColor = "Yellow", + sour = true } for key, value in pairs(testDictionary) do @@ -213,9 +213,9 @@ for key, value in pairs(testDictionary) do end --[[ Resulting output: -FruitName Lemon -Sour true -FruitColor Yellow +fruitName Lemon +sour true +fruitColor Yellow ]] ``` @@ -229,19 +229,19 @@ To remove or erase a key-value pair from a dictionary, set its value for a key t ```lua local testDictionary = { - FruitName = "Lemon", - FruitColor = "Yellow", - Sour = true + fruitName = "Lemon", + fruitColor = "Yellow", + sour = true } -testDictionary["Sour"] = nil +testDictionary["sour"] = nil for key, value in pairs(testDictionary) do print(key, value) end --[[ Resulting output: -FruitName Lemon -FruitColor Yellow +fruitName Lemon +fruitColor Yellow ]] ``` @@ -280,7 +280,7 @@ To copy a table without any nested tables, Luau offers the `Library.table.clone( local original = { key = "value", engine = "Roblox", - playerID = 505306092 + playerId = 505306092 } local clone = table.clone(original) @@ -314,7 +314,7 @@ With the function in place, you can make a deep copy as follows: local original = { key = "value", playerInfo = { - playerID = 505306092, + playerId = 505306092, playerName = "PlayerName" }, otherInfo = { @@ -339,11 +339,11 @@ To freeze a table without any nested tables, Luau offers the `Library.table.free local target = { key = "value", engine = "Roblox", - playerID = 505306092 + playerId = 505306092 } table.freeze(target) -target.playerID = 1 --> attempt to modify a readonly table +target.playerId = 1 --> attempt to modify a readonly table ``` ### Deep Freezes @@ -370,7 +370,7 @@ With the function in place, you can deep freeze a table as follows: local target = { key = "value", playerInfo = { - playerID = 505306092, + playerId = 505306092, playerName = "PlayerName" }, otherInfo = { @@ -381,5 +381,5 @@ local target = { } deepFreeze(target) -target.playerInfo.playerID = 1 --> attempt to modify a readonly table +target.playerInfo.playerId = 1 --> attempt to modify a readonly table ```