Types

Types

Booleans

A boolean is a value of either true or false. There are two boolean literals: True and False. Booleans are referred to asbool in Jingle.

Integers

Integers are whole numbers without floating points. They aren't dissimilar to other languages. Examples include:

0
1234
-5678
1
23
456
7890

Integers by default are signed 64-bit but can be unsigned or signed ranging in width from 8-128 bit values.

Floats

Floats are floating-point numbers. They aren't dissimilar to other languages. Examples include:

Floats in Jingle are double-precision floating points.

Strings

A string is an array of characters. At the moment they are encoded in UTF-8. They are enclosed in quotes:

There are also a handful of escape characters that are usable:

Interpolation

Strings allow for interpolation. If you have a hashtag (#) followed by a expression enclosed in braces ({ }) then the expression given will be evaluated:

Expressions in the braces can be arbitrarily complex. An interpolated expression can even contain a string literal which in turn has its own nested interpolations, but doing that obviously gets unreadable pretty quickly.

Ranges

A range is a little object that represents a consecutive range of numbers. They don’t have their own dedicated literal syntax. Instead, they implement the .. and ... operators to create inclusive and exclusive ranges, respectfully:

Ranges are commonly used for iterating over sequences, like in for statements, but are useful in other ways too. For example, you can use them as arguments to a list subscript:

Nil

There is a special type of Nil which functions like None in Python. It indicate no value or a null value. If you call a method that doesn’t return anything and get its returned value, you get Nil back.

Any

There is another special type known as Anywhich allows you to force a variable to be dynamically-typed. There aren't many cases where this would be used, other than if you want to turn a typed variable into a normal variable or if you want to remove the type declaration from a variable.

Last updated

Was this helpful?