Example of the Returning Option
Policy
The following is an example of the returning Option
policy. In this example, an overflow occurs in an attempt to calculate the square of Int64.Max, and None is returned.
import std.overflow.*
import std.math.*
main() {
let a: Int64 = Int64.Max
println(a.checkedPow(UInt64(2)))
}
The running result is as follows:
None