This topic provides a reference table for all automatic type conversions to boolean, sorted by merit.
Fair Conversions
This section lists all fair
conversions to the boolean type. A fair conversion indicates the types involved are closely related in a data layout sense, though not necessarily in a conceptual sense. Although these conversions may fail or narrow, it is nevertheless considered decent practice to rely upon them. Examples in this category include conversions from booleans to integers, or from curves to intervals.
| From | Explanation |
|---|---|
| angle | Returns true for all angles except those near zero. |
| complex number | Returns true for all complex numbers except those near zero. |
| integer | Returns true for all integers except zero. |
| integer (big) | Returns true for all integers except zero. |
| number | Returns true for all numbers except those near zero. |
Plausible Conversions
This section lists all plausible
conversions to the boolean type. A plausible conversion indicates a non-straightforward, but still a reasonable conversion between two types sharing a salient quality, or where one is an obvious sub-type of the other. Any plausible conversion can also be achieved through the explicit use of standard components. Examples in this category include conversions from points to planes, or from boxes to rectangles.
| From | Explanation |
|---|---|
| interval | Returns true for all intervals except near-empty ones. |
Strange Conversions
This section lists all strange
conversions to the boolean type. A strange conversion indicates a peculiar, but occasionally sensible, translation between types. However, it is equally likely that the conversion was not intended and thus signals a mistake in the algorithm design, which is why this conversion level is the default for showing conversion warnings. Examples in this category include the conversion from decimal numbers to languages, or from views to meshes. Any strange conversion can also be achieved through the explicit use of standard components.
| From | Explanation |
|---|---|
| vector | Returns true for all vectors except those with near-zero length. |