Skip to content

Intrinsic Procedure __greater_than_or_equal__

IsaacShelton edited this page Mar 21, 2022 · 1 revision

'__greater_than_or_equal__' function

The __greater_than_or_equal__ function can be defined to allow additional types to be used with the greater-than-or-equal >= operator.

func __greater_than_or_equal__(a $A, b $B) bool {

}

where $A and $B are any valid types

Usage Example

import basics

func main {
    a Letter = letter('a'ub)
    b Letter = letter('b'ub)
    
    printf("%S >= %S  =>  %b\n", toString(a), toString(b), a >= b)
}

struct Letter (char_code ubyte)

func letter(char_code ubyte) Letter {
    l POD Letter
    l.char_code = char_code
    return l
}

func __greater_than_or_equal__(lhs, rhs Letter) bool {
    return lhs.char_code >= rhs.char_code
}

func toString(letter Letter) String {
    return string(&letter.char_code, 1)
}
a >= b  =>  false
Clone this wiki locally