136
I don't want to use ternaries
(lemmy.xylight.dev)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
One of my guilty pleasures is to rewrite trivial functions to be statements free.
Since I'd be too self-conscious to put those in a PR, I keep those mostly to myself.
For example, here's an XPath wrapper:
Which you can use as
$$$("//*[contains(@class, 'post-')]//*[text()[contains(.,'fedilink')]]/../../..")
to get an array of matching nodes.If I was paid to write this, it'd probably look like this instead:
Seriously boring stuff.
Anyway, since var/let/const are statements, I have no choice but to use optional parameters instead, and since loops are statements as well, recursion saves the day.
Would my quality of life improve if the lambda body could be written as
=> if n then a.push(n), $$$(q,d,x,a) else a
? Obviously, yes.Reminds me when my I did all my homework using list comprehension, ternary operations, and lambda expressions because it was boring. Here's an example
you monster