Created
June 12, 2016 17:15
-
-
Save exerro/f5b81c1054bf6075eb02c481f8599318 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function isByte( n ) | |
return type( n ) == "number" and n >= 0 and n < 256 | |
end | |
types.define( "byte", { type = "custom", value = isByte } ) | |
types.define( "optional byte", "byte | nil" ) | |
types.define( "colour", "{ byte, byte, byte, optional byte }" ) | |
print( types.check( { 1, 2 }, "colour" ) ) --> false | |
print( types.check( { 1, 2, 3 }, "colour" ) ) --> true | |
print( types.check( { 1, 2, 3, 4 }, "colour" ) ) --> true | |
print( types.check( { 1, 2, 3, 4, 5 }, "colour" ) ) --> false | |
print( types.check( { 6127, 32189, 412 }, "colour" ) ) --> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment