6 ms·
> And then it ruined us with implicit returns What was so ruinous about implicit returns? That's one of the things I missed most when leaving CoffeeScript. ECM
by brianshaler 2y ago
> And then it ruined us with implicit returns
What was so ruinous about implicit returns? That's one of the things I missed most when leaving CoffeeScript. ECMAScript only partially adopted it (single statement fat arrow functions) which probably muddies the waters for people trying to learn and understand the language's behavior.
Since it's optional for the caller to use or assign the return value of a function, I don't see much problem with functions defaulting to returning something. Maybe it just fits with my personal preference of functions returning a value and not having side-effects..
- sciolistse 2y agoprobably gets better with use but having to remember not to put a loop as the last statement of a function, because it would make it return an array of the last statement of the loop body, caught me off guard enough times to get annoying. easy enough to add an extra line with just 'undefined' as the last statement of the function of course. but then you do need to remember that.
- hosh 2y agoI came from Ruby and Elixir. It is always implicit returns. When I started writing TypeScript, having to have explicit returns was my number 1 bug. People can adapt either way. You can write more concise code with implicit returns and "everything is an expression".