- cross-posted to:
- lemmyshitpost@lemmy.world
- cross-posted to:
- lemmyshitpost@lemmy.world
cross-posted from: https://lemmy.blahaj.zone/post/31679150
proportional reaction
its not my fault
return apple == red ? true : falseis so cute. :3Not object oriented enough
return fruit.isColor(Color.RED)
That
return a === b ? true : false
Is bothering me way too much. Just
return a === b
return true === (a === b) ? true : falseNow that I think of it, the return of false should be a casted integer. Just to add horror.

You can have my ternary operator when you pry it from my cold, dead hands.
Ternary operators are the one thing I really miss from Go.
# I mean, Crystal does have a ternary operator, too... bar = case something in "aaa" then true in "bbb" then false end foo = if bar 69 else 42 end;; Or CASE or IF or COND or whatever (let* ((bar (ecase (something) (:aaa t) (:bbb nil))) (foo (if bar 69 42))) )Yeah, the problem isn’t “conditional expressions”, it’s “terse syntax”, and operator rules that you need to just memorize because they’re special and different. Also being limited such that you need to nest the extremely deeply if you, for whatever, you need to have a complex inline condition.
I like the case expression , although I mostly know it from erlang.
I’ve been called slurs before for using immediately invoked anonymous function expressions with switch cases in JS
const [val1, val2] = (() => { switch(whatever) { case "foo": return [1, 2]; case "bar": return [3, 4]; default: return [0, 0]; } }))();const [val1, val2] = ({ "foo": [1, 2], "bar": [3, 4], })[whatever] || [0, 0];🤫
ternary operator rules though
TypeScript library devs are shivering in cold sweat right now







