Built In Types: Introduction
This section covers the different built-in types available in Hack.
Hack has the following primitive types: bool, int, float, string, and null.
Hack supports union types, like:
- num, where
floatare subtypes of
- arraykey, where
stringare subtypes of
The Super Type
Hack's super type is mixed, which represents any value. All other types are subtypes of
A few things to know when working with
mixed as a type:
- The opposite of
mixedis nothing, a special type at the "bottom" of all other types.
mixedis equivalent to
?nonnull. nonnull is a type that represents any value except
There are three types of Hack Arrays. They are: vec, keyset, and dict.
Though not built-in as types, other alternatives exist in Hack Collections.
Other Built-In Types
Hack has other built-in types too, like: enum (with enum class and enum class labels), shape, and tuples.
Function Return Types
Other types like noreturn and void are only valid as function return types .
These last few types are special in their utility and/or versatility: classname, dynamic, and this.
Thank You! If you'd like to share more feedback, please file an issue.