News for hackers. Stuff that matters.
Re:The Ultimate Conditional Syntax by trealira on Sunday October 20, 2024 @07:02PM (#41899208)
It looks like it could be more concise sometimes. For instance, you could have this:

  if f(x) is Some(a) and g(x, a) is Some(Right(b)) then h1(a, b) else h2(x)
The equivalent pattern matching with a match expression in pseudo-ML:

  match f(x) with
    None -> h2(x)
    Some(a) ->
      match g(x, a) with
        Some(Right(b)) -> h1(a, b)
        _ -> h2(x)

There are no comments on this comment yet.