#{} is not equal to {}

1 messages · Page 1 of 1 (latest)

frail ingot
#
local canUpgrade = false
print(parentUpgrades)
if parentUpgrades == {} then
   canUpgrade = true
end
print(canUpgrade)

line 25 prints {} (as it should)
line 29 prints false (should not)
for some reason, the if statement says parentUpgrades is not equal to {} even though the print statement clearly said it was. i tried nil and even an empty table equal to {} instead of {} in the if statement, nothing changed

past token
#

Each table occupies a different array of contiguous bytes in memory, each with a separate initial memory address

#

You're not checking if a table is empty, you're checking if a table is equal to another

past token
#

To check if an array is empty, use the length operator to get the number of elements within the array, and compare that number to 0:

if #array == 0 then
#

To check if a dictionary is empty, query the first key-value pair via next, and compare it to nil:

if next(dictionary) == nil then
#

The latter method works for both dictionaries and arrays

deft zodiac
#

uhn

#

basically like doing print(Instance.new("Part") == Instance.new("Part"))

#

it will always be false unless they refer to the exact part

frail ingot
frail ingot
#

i forgot tables are like those weird IDs