Comment

Comment by fovc

A common variant of this is the Boolean argument to flip between function modes

    doAOrB(args, aOrB: bool)
Especially if the toggle gets used in 3-4 places or more in the body, control flow is a nightmare to follow. Instead of 2 paths to read, you have to mentally coalesce 2^n paths into 2. Worst-case scenario is when args has different meanings depending on the value of aOrB.

    @param flag: if set and if aOrB is true, warnings log to stdout and die, otherwise warnings are saved in the foobar field of args
parent fovc 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton