Module:IP: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Undid revision 731014195 by Johnuniq (talk) this breaks equality testing, as __eq needs to use the same function object, not just an equivalent anonymous function
(mt variable not needed for Subnet; this is similar to IPAddress)
(Undid revision 731014195 by Johnuniq (talk) this breaks equality testing, as __eq needs to use the same function object, not just an equivalent anonymous function)
Line 489:
-- is a Subnet object.
local uniqueKey = {}
 
-- Metatable
local mt = {
__eq = function (self, obj)
return self:getCIDR() == obj:getCIDR()
end,
__concat = function (self, obj)
return tostring(self) .. tostring(obj)
end,
__tostring = function (self)
return self:getCIDR()
end,
__metatable = uniqueKey,
}
 
-- Private static methods
Line 506 ⟶ 520:
makeSubnetFromRaw = function (rawIP, bitLength)
-- Set up structure
local obj = setmetatable({}, {mt)
__eq = function (self, obj)
return self:getCIDR() == obj:getCIDR()
end,
__concat = function (self, obj)
return tostring(self) .. tostring(obj)
end,
__tostring = function (self)
return self:getCIDR()
end,
__metatable = uniqueKey,
})
local data = {
rawIP = rawIP,
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu