I admit it: I like Python’s ternary operator
charemza.name
charemza.name
[1]. The MultiWayIf extension for GHC is a great example of how to optimize this idiom for regularity.
Then again, many things that supposedly would "never" make it into the language, have been added over time anyway, including the ternary if. So who knows...
Ah, but it seems that there's some disagreement about this being unnecessary :).
Btw, MultiWayIf is a much more powerful (bad word choice?) than 'switch' because it's more flexible at no additional syntactic cost. FWIW, I mostly just like it because of the extreme syntactic regularity of MWI.
(I have no horse in the race. I just use Python occasionally as a scripting language, but I've been moving over to Haskell+Stack for scripts, so... )
2) I also like it. Mostly because it was missing for so long and that has always been very annoying.
mySignal <= "1111" when some_state = '1' else "0011" selected_value =
condition_1 ?
value_1 :
condition_2 ? value_2 : value_3 selected_value =
condition_1 ? value_1 :
condition_2 ? value_2 :
value_3i think it makes it more complicated to think about because it requires some backtracking in thought
Unless you want to use mutation you have to use it in python, and then you end up with ugly chains if you want brevity.
It certainly sounds like a useful feature, as someone who writes a lot of JavaScript I can see the value (and I believe a form of this is coming to JS in the form of `do` expressions).