Skip to content

is method has problems when value is nil. workaround? #21

Description

@Shadowblitz16

There seems to be a problem with the design of the is method.
You can't do things like nil:is(SomeType)
This makes it pretty much useless for type checking as you have to guarantee that class variables are never nil.

I tried implementing it as a helper function with a little change...

function is(self, T)
  if self == T then
      return true
  else
      local mt = getmetatable(self)
      while mt do
      if mt == T then
          return true
      end
      mt = getmetatable(mt)
      end
  end
  return false
end

but it has the same problem.

Maybe there is a way to get around it?
This would also effect #20

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions