you are viewing a single comment's thread
view the rest of the comments
[–] 26 points 2 years ago (7 children)

I'd take a not or "if not" operator tbh.

  • source
  • hideshow 7 child comments
  • [–] 9 points 2 years ago* (5 children)

    It has a not keyword it's used for pattern matching.

    if (x is not null)
    
  • source
  • parent
  • hideshow 5 child comments
  • [–] 3 points 2 years ago (3 children)
  • [–] 2 points 2 years ago (2 children)

    Pattern matching is different.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago (1 child)

    Yeah, I just said it since you used it with null. I used it a lot for enums

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 2 years ago*

    The type matching is the most common thing I use it with. Combined with inline variables.

    if (x is string { Length: 5} s)
    {
        // do stuff with s
    }
    

    And switch expressions.

    As a side note inline variables are amazing haha

  • source
  • parent