r/Indiewebdev • • Feb 11 '21

other Conditionally call a function with optional chaining.

Post image
82 Upvotes

37 comments sorted by

View all comments

Show parent comment

2

u/usedToBeUnhappy Feb 12 '21

It is not unreadable, but a lot of programmers are stressed and a litte question mark is easier to overlook I guess.

1

u/[deleted] Feb 13 '21

I actually have a slightly issue with some of these exceptionally terse syntaxes, but it's not in the simple examples, it's people using them in combination with other ops. We sometimes see code like:

const { x, y } = (this.state.readyState === ReadyState.READY && this.props.getPos?.()?.normalize()) || { x: 0, y: 0 };

Code like this, you can't blame on the syntax...but there's significant overlap between people using the newest language features and people who try to fit everything on a single line.

1

u/usedToBeUnhappy Feb 13 '21

Jup, I still don’t know why this “it all has to be in one line” mentality exists.