trait
Absable
The Absable
trait describes a type that defines an absolute value operation.
Types that conform to Absable
will work with the builtin abs
function.
The absolute value operation always returns the same type as the input.
For example:
struct Point(Absable):
var x: Float64
var y: Float64
fn __abs__(self) -> Self:
return sqrt(self.x * self.x + self.y * self.y)
Implemented traits
AnyType
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
😔 What went wrong?