Feedback
Add user-defined conversion operators
- Status
- Fixed
- Fixed in
- v26.6.4
- Last updated
- 2026-06-15
Public summary
Add inbound user-defined conversion operators for custom ObjoBasic types. A target class can declare Shared Function Operator_Convert(value As SourceType) As TargetType, allowing values such as Integer, Double, or String expressions to initialise, assign to, or pass into that target type when a matching conversion overload exists.
Example:
Class Int128
Shared Function Operator_Convert(value As Integer) As Int128
Return New Int128(value)
End Function
End Class
Var value As Int128 = 55
This is conversion overloading, not assignment overloading. Assignment remains a normal type/storage operation after the compiler resolves a valid direct assignment or conversion.