Would if/else have been considered optimal to you if you hadn’t already been conditioned (ha!) that way by other programming languages?
“When” actually seems better in a purely declarative language.
Re:When or If
by andreareina on Monday March 14, 2022 @11:43PM
(#30681444)
Maybe it's prior exposure to lisp, but I wouldn't expect "when" to have an "else" clause. Can't think of an idiomatic natural-language case with that structure either.
I have never used SASS and if/else is obviously better than when/else.
It was the same with Array includes and contains, wasn't it?
Re:When or If
by kretaceous on Monday March 14, 2022 @02:58PM
(#30676603)
Also, Array.flat was chosen instead of Array.flatten because of a popular 3rd party library's function of the same name. I think it was Lodash.
It was mootools.
https://developers.google.com/web/updates/2018/03/smooshgate
Re:When or If
by mananaysiempre on Monday March 14, 2022 @04:06PM
(#30677528)
... And underscore/lodash use the _(...) wrapper approach pioneered by jQuery’s $(...) precisely to avoid monkey-patching builtin objects like Mootools did (as well as some others I think, but I don’t really remember).
I find it ironic that the css "when/else" draft spec uses "if" for describing the conditional scenarios in plain english. As if the spec itself admits the syntax they are choosing is clearly sub-optimal.