What’s a Type?
The terminology around types in programming languages can be confusing because each language community uses the terms slightly differently.
Most generally, setting the type of a variable, attribute, or method argument limits the set of values that can be assigned to that variable, attribute, or method argument. The type also determines the behavior of the variable within the program. For example, the result of x / y depends on the type of x and y. In many languages, the result will be different if the numbers are integers than if they are floating-point types.
Many programming languages have a set of “basic types” that can be used, often including strings, boolean values, different kinds of numerical values, and so on. Ruby doesn’t ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access