BrowserREPL-button-tip-on BrowserREPL-button-tip-off

EditButtonTip 2024-08-04

class X::Numeric::CannotConvert

Error while trying to coerce a number to another type

class X::Numeric::CannotConvert is Exception { }
Code

Occurs when an attempt to coerce an Inf or a NaN to a Numeric type.

For example

say Inf.Int;
CATCH { default { put .^name, ': ', .Str } };
# OUTPUT: «X::Numeric::CannotConvert: Cannot convert Inf to Int␤»
Code

Most other conversion errors throw X::Numeric::Real.

Methods§

method source§

method source()
Code

Returns the value that failed to coerce.

method target§

method target()
Code

Returns the type to which the coercion was attempted.

method reason§

method reason(--> Str:D)
Code

Returns the reason that the conversion failed.