r/badcode • • Apr 17 '21

c++ When your teammate "refactor" your code

Post image
2.5k Upvotes

216 comments sorted by

View all comments

298

u/[deleted] Apr 17 '21

This is why I like languages with nice pattern matching, as it can often make code like this compact in a nice way. Something along the lines of

match (condition1, condition2) {
    (true, true) => do_anything1(),
    (false, _) => do_anything2(),
}

103

u/Flaming_Eagle Apr 17 '21

I didn't know how badly I needed this until now

20

u/CatpainCalamari Apr 18 '21

Come to the scala side, we have pattern matching :)

15

u/[deleted] Apr 18 '21

or Rust(both nice languages)

15

u/nuephelkystikon Apr 18 '21

Or Python if you're willing to wait half a year for the merge.

1

u/ThatGuyFromSlovenia Apr 18 '21

OCaml is the one I use.