Trait in prelude::ops auto-imported

Lt

trait Lt<T>
Source: compiler/src/builtin_docs/prelude/ops.hy

The less-than operator <.

a < b on a type with an Lt instance calls lt(a, b).

Required methods#

NameDescription
ltReturns true when a is less than b.

Examples#

use tests::assert;
class Version {
    pub n: int,
}

impl Lt for Version {
    pub fn lt(Version a, Version b) -> bool {
        return a.n < b.n;
    }
}

fn main() {
    assert!(new Version(1) < new Version(2));
}

See also#

  • Add: The addition operator +.
  • Sub: The subtraction operator -.
  • Mul: The multiplication operator *.
  • Div: The division operator /.
  • Neg: The unary negation operator -x.
  • Rem: The remainder operator %.
  • Pow: The exponentiation operator **.
  • Num: The numeric bundle: Add, Sub, Mul, Div, Neg, Rem and Pow.
↑ ↓ navigate ↵ open