Styling nested ifs

I'm not sure where the best place for this is or if it's described elsewhere, but I wanted to share how I like to style my nested ifs.

Consider code where there are a few predicates p1, p2, p3. Nesting ifs can get complicated, and can fail to show the top-level nature of the branching. Instead, I always use

match (p1, p2, p3) {
    (true, true, _) => ,
    (true, false, true) =>,
//    ...
}
4 Likes