classic
classic copied to clipboard
Error free as method
function Object:as(T)
if self.is(T) then
return self
end
return T
end
@Shadowblitz16 what? More details please?
Its a suggestion for a as
method.
basically its the same as is
but it returns the object if its of that type instead of a bool.
If not it either returns nil or a temporary value of that type so you don't get nil errors when accessing the data.
You can easily create your own method for that, i dont think this is needed in classic unless im mistaken.
It would be easy to create unless you implement a work around for is
and as
or nil instances