Skip to main content
Log in

Mojo trait

Ceilable

The Ceilable trait describes a type that defines a ceiling operation.

Types that conform to Ceilable will work with the builtin ceil function. The ceiling operation always returns the same type as the input.

For example:

from math import Ceilable, ceil

@value
struct Complex(Ceilable):
var re: Float64
var im: Float64

fn __ceil__(self) -> Self:
return Self(ceil(self.re), ceil(self.im))
from math import Ceilable, ceil

@value
struct Complex(Ceilable):
var re: Float64
var im: Float64

fn __ceil__(self) -> Self:
return Self(ceil(self.re), ceil(self.im))

Implemented traits

AnyType, UnknownDestructibility

Methods

__ceil__

__ceil__(self: _Self) -> _Self

Return the ceiling of the Int value, which is itself.

Returns:

The Int value itself.