#131chained comparison operator

  • avatar~clovercommented · 1 year ago
    Author
    Owner
    if 5 < y <= 6 {
    
    }
    

    comparison operator may be chained any number of times in a row

    let result = 6 > 2 >= 1 > 6; // false
    

    comparison chains may be either

    • all equals
    • all less than / less than equal
    • all greater than / greater than equal

    ex:

    | error: comparison chain cannot mix less than and greater than
    | if 3 < y > 2 {
    +----=========
    

    this might be solved better by range syntax but its worth exploring

  • avatar~clover changed the status to Todo · 1 year ago