Skip to content
FutureBlitz

    Install

    Import std.core.interfaces

    Comparable

    std.core.interfaces

    interface

    Public Interface Comparable Extends Equatable

    An order: what < says, which the other comparisons follow unless a type gives its own.

    Examples

    Struct Version Implements Comparable
        Field Major: Int
        Field Minor: Int
    
        Operator <(a: Version, b: Version): Bool
            Return a.Major < b.Major || a.Major == b.Major && a.Minor < b.Minor
        End Operator
    End Struct
    
    Expect(Version(1, 2) < Version(1, 10))
    Expect(Version(2, 0) >= Version(1, 9))
    Expect(Max(Version(2, 0), Version(1, 9)).Major == 2)

    std/core/interfaces.fb, line 50

    • Operator <(a: Self, b: Self): Bool operator #

      Whether a comes before b.

    • Operator >(a: Self, b: Self): Bool operator #

      Whether a comes after b.

    • Operator <=(a: Self, b: Self): Bool operator #

      Whether a comes before b or is equal to it.

    • Operator >=(a: Self, b: Self): Bool operator #

      Whether a comes after b or is equal to it.

    Report an issue with this page or with FutureBlitz on GitHub.