Primitive types are a class of data type which represent fundamental values which cannot be expressed more simply. They're as basic as you can get. KBMax's Snap language has the following primitives available to use. These are accessible in all rules.
Boolean
Booleans take one of two values, true or false. They are essential for all logical blocks such as the "if" block.
Text
Text values consist of alphanumeric content, as well as symbols.
Number
Number values represent all of the real numbers. You can perform math operations on number blocks to return new numbers. Unlike some other languages, Snap has no distinction between integers, floats, and doubles.
Date
Date values represent a specific date-time value, granulated to seconds. You can perform math on dates (such as to find the number of days between one date and another, or to add hours to a date value) and format them to text using a special formatting string for user-readable output.
Arrays
See Arrays for detailed information.
Maps
See Maps for detailed information.
The Any Type
Sometimes, you need to handle data but you don't know exactly what type it might be. The special "any" type is a block which accepts any type as input. If "any" is used as a output, it means the output's data type cannot be known due to some ambiguity. For instance, a block may take a field's value by some arbitrary name that is passed in. Because fields can use different data types, and it's unknown which field is going to be passed back, the value returned could be a boolean, number, or text.
If a block's input is expecting a specific data type, and a block returning "any" is connected, it will still invoke an error until you cast that block's value to the expected type.
Examples
Example 1
In many cases you can cast a value to another type. In this case, because variable x is a text, "42", it must be converted to a number in order to be used in a math operation. After clicking "Cast to Expected Type" this variable will be enclosed in a cast block. Note that not all types can be convertible to another. For instance, if x were an array of objects, there would be no way for Snap to know how to convert that complex value to a number.
Example 2
Any types can be problematic at times. In this case, the Serialize to JSON block has a connector which takes any as a type. This means passing in a Configurator type is valid. However, if you try to apply a value of type any to the json variable, which is expecting the specific type of text, an error will be thrown. You can still correct the error by casting the any value to text; however keep in mind this cast might not always work as expected if the actual value is a type that is not convertible to the expected type at runtime.
Don't see a type you need? Create your own.
If you need to store information, and none of the types above meet your needs, you can define your own custom type.