mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Make nil checks more robust.
This represents an evolution in how I've been thinking about Lua -- using boolean coercion is generally a bad idea I think because it obscures the underlying types. It also makes it so that if a boolean is eronneously passed into a function, and it happens to be a 'false' value, it will be coerced into the nil case instead of being reported as an error, no matter how unintuitive the resulting error might be.
This commit is contained in:
parent
4b2f27b26d
commit
b60bfc7495
1 changed files with 7 additions and 7 deletions
|
|
@ -94,7 +94,7 @@ function Reconciler:_reconcileChildren(rbx, item)
|
||||||
while true do
|
while true do
|
||||||
local itemChild, rbxChild = findNextChildPair(item.Children, rbxChildren, visited)
|
local itemChild, rbxChild = findNextChildPair(item.Children, rbxChildren, visited)
|
||||||
|
|
||||||
if not itemChild then
|
if itemChild == nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ function Reconciler:_reconcileChildren(rbx, item)
|
||||||
while true do
|
while true do
|
||||||
local rbxChild, itemChild = findNextChildPair(rbxChildren, item.Children, visited)
|
local rbxChild, itemChild = findNextChildPair(rbxChildren, item.Children, visited)
|
||||||
|
|
||||||
if not rbxChild then
|
if rbxChild == nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ function Reconciler:_reify(item)
|
||||||
reparent(self:_reify(child), rbx)
|
reparent(self:_reify(child), rbx)
|
||||||
end
|
end
|
||||||
|
|
||||||
if item.Route then
|
if item.Route ~= nil then
|
||||||
self._routeMap:insert(item.Route, rbx)
|
self._routeMap:insert(item.Route, rbx)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -153,8 +153,8 @@ end
|
||||||
]]
|
]]
|
||||||
function Reconciler:reconcile(rbx, item)
|
function Reconciler:reconcile(rbx, item)
|
||||||
-- Item was deleted
|
-- Item was deleted
|
||||||
if not item then
|
if item == nil then
|
||||||
if rbx then
|
if rbx ~= nil then
|
||||||
self._routeMap:removeByRbx(rbx)
|
self._routeMap:removeByRbx(rbx)
|
||||||
rbx:Destroy()
|
rbx:Destroy()
|
||||||
end
|
end
|
||||||
|
|
@ -163,7 +163,7 @@ function Reconciler:reconcile(rbx, item)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Item was created!
|
-- Item was created!
|
||||||
if not rbx then
|
if rbx == nil then
|
||||||
return self:_reify(item)
|
return self:_reify(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ function Reconciler:reconcileRoute(route, item, itemRoute)
|
||||||
local child = rbx:FindFirstChild(piece)
|
local child = rbx:FindFirstChild(piece)
|
||||||
|
|
||||||
-- We should get services instead of making folders here.
|
-- We should get services instead of making folders here.
|
||||||
if rbx == game and not child then
|
if rbx == game and child == nil then
|
||||||
local success
|
local success
|
||||||
success, child = pcall(game.GetService, game, piece)
|
success, child = pcall(game.GetService, game, piece)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue