You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: clarify type system characteristics in types.md
Update the documentation to specify that explicit casting is required between different types, with the exception of conversions between primitive reference types and their corresponding fundamentals. Adjust code examples to reflect this change, enhancing clarity and understanding of the type system.
Copy file name to clipboardExpand all lines: docs/reference/types.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -220,7 +220,7 @@ fun CanReassign(var str: String): Void {
220
220
## Type System Characteristics
221
221
222
222
**Static typing:** Every variable and expression has a type checked at compile time
223
-
**No implicit conversions:** Explicit casting required between different types
223
+
**No implicit conversions except builtin wrappers:** Explicit casting required between different types, except for conversions between primitive reference types and their corresponding fundamentals.
224
224
**Type safety:** Prevents many common errors
225
225
**Nullable types:** Any reference type (including primitive reference types) can be made nullable by appending `?`. Fundamental types cannot be nullable.
226
226
@@ -236,7 +236,7 @@ val result: float = (intVal as float) + floatVal // OK: Explicit conversion
236
236
// Using primitive reference types (implicit conversion)
237
237
val refInt: Int = 42 // Implicit conversion from literal
238
238
val refFloat: Float = 3.14 // Implicit conversion from literal
239
-
val sum: Int = refInt + refFloat // Implicit: Int + Float -> Int
239
+
val sum: Int = refInt + (refFloat as Int) // Explicit conversion
240
240
val fundamentalSum: int = sum + 10 // Implicit: Int + int -> int
0 commit comments