3 ms·
I've found I often prefer reading and writing the actual guts of the inlined function, over naming it something semantically significant. It's often difficult t
by hughw 11y ago
I've found I often prefer reading and writing the actual guts of the inlined function, over naming it something semantically significant. It's often difficult to craft a good English name for the function. It can inhibit understanding to have to change context to learn what a function does by looking at its code (OtherModule.capitalizeEveryWordInThe). There can be small semantic variations (capitalizeEveryWordInThe, capitalizeEveryWordButFirstInThe) requiring an exploding util package.
Edit. I'm saying I find the one-liner form frequently more understandable than one embodied in a function.
- justsaysmthng 11y agoYeah, I guess it depends on how many instructions are in that one liner and how intelligible it is three years from now. The expressiveness of the language also helps a lot. a.map { x in x * 3 } is probably intelligible enough (in Swift) so no need for util.multiplyEveryElementBy3(a)..