typing.lua 386 B

123456789101112131415161718192021222324252627282930313233
  1. typing = {}
  2. --returns keys of mismatches
  3. typing.matchSignature = function(tab, sig)
  4. for key, v in pairs(sig)
  5. do
  6. if type(tab[key]) ~= v
  7. then
  8. return key, v, type(tab[key])
  9. end
  10. end
  11. end
  12. --[[
  13. local testSignature =
  14. {
  15. a = "number",
  16. b = "string",
  17. c = "boolean",
  18. d = "nil"
  19. }
  20. local test =
  21. {
  22. a = 1,
  23. b = "",
  24. c = false,
  25. }
  26. print(typing.matchSignature(test, testSignature))
  27. ]]