3 ms·
There is no one size fits all. In a many cases I'd still rather have three or more versions of a function, many which may just be very thin shims to accommodat
by lttlrck 2y ago
There is no one size fits all.
In a many cases I'd still
rather have three or more versions of a function, many which may just be very thin shims to accommodate that scenario than 10 copy/pastes of variations. Or shim at the call site and keep one function if that suits.
- SoftTalker 2y agoIf a function does different things in different circumstances it should usually be split into different functions. Languages like Erlang which can have different versions of a function, selected by pattern matching (with optional guards) make this convenient: Name(Pattern11,...,Pattern1N) [when GuardSeq1] -> Body1; ...; Name(PatternK1,...,PatternKN) [when GuardSeqK] -> BodyK.