any
is a special type that is used for type hinting collection type variables where the types of all the possible items in the collection is unknown.list[any]
allows a list of any type objects (list
also works).tuple[any]
allows a tuple of any type objects (tuple
also works).dict[str, any]
is a dictionary with string keys and any type values.dict[any, any]
allows both keys and values to be any hashable type (dict
also works).set[any]
is a set of any hashable typeany
only works for collection types. For now, I don't think like you should be allowed to declare an any
type variable.null
is a special variable that represents nothing.null
, the variable can be typed with the none
typenull
then the type must be suffixed with a ?
character, indicating that the variable is nullable.let a: list[int] = null # ERROR
let b: list[int]? = null # OK
def f() -> str = return null # ERROR
def f() -> str? = return null # OK
?
suffix, then the type is considered nullable and can have null
assigned to it.null
values the interpreter will warn them.!
character to the variable name.let s: str? = 'abc' # s is of type str?
s = s! # now s is of type str
!
is used when the value of a nullable is null, an error will be thrown?
character.int
.float
.oct
hex
num
is a super type for all numeric types that can be used for param and return types in functions that can handle int
and float
types.Drizzle
will have methods (x: float = 3.as(float)
).int
and float
type for 64-bit integers and 64-bit floats for now.'Hello, World'
.'We just converted #{x} into a float'
).str
is used.true
, false
.bool
is used.a: list[int]: [1, 2, 3]
b: list: [1, 'abc', 3.1415]
b[0] = 2 # => OK
c: tuple[int] = (1, 2, 3)
d: tuple = (1, 'abc', 3.1415)
d[0] = 2 # => ERROR
let x: tuple[int] = (1)
and not have to add the extra ,
to denote a one-item tuplemap: dict[str, str] = {'a': 'b', 'b': 'a'}
map2: dict[str, any] = {'a': 'b', 'b': 2}
map3: dict = {0: 'a', 'b': 1}
s1: set[int] = {1, 2, 3}
s2: set = {1, 'b', 0xa}
{}
literal can be used to define empty sets and empty dicts with no hassle*!if s == {}
) but hopefully the parser will be able to handle it.0..5
0...5
dict
, then they can by typed using union types.|
character.dict[str, str | int]
is the type for a dictionary with string keys and either string or integer values.((num, num) -> num)
is the type for functions that take in two num
type parameters and return a num
type parameter.list[list[int | str | set[str | int]] | dict[str, int | list[str | int | dict[str, str]]]]
.