Conditions are boolean values , true or false. It is true if it meets the requirement, false otherwise. That is expressions (conditions) are...
For further actions, you may consider blocking this person and/or reporting abuse
I really like the ternary operator in theory. Beeing able to have branching in an expression is lovely, but I hate how hard it is to read in JS (exponentially worse for nested branches).
I think python chose a way better syntax for expression branching:
Instead of:
You got:
That may be true because some people will disagree with you. But generally, python has a better syntax. That is why Python is used for complex code structure in AI, machine Learning, data science, etc.
If you already know JavaScript on the browser or web, I recommend trying out Brython...
I'll give Brython a go, never heard of it :D
But JS has it's pros, too. In python I do miss having functions as first class objects (although that might help python, still. Making it more clear). And everything async feels slugish in python compared to js.
I enjoy switching back and forth every now and again.
That's because you used Python... It happens to everyone at some point...
FYI: dev.to/peerreynders/comment/1a73d
I do feel more and more drawn towards a more functional / declarative style of programming. It makes it (at least for me) more intuitive (both when reading and writing), than either imperative or object oriented.
I'm not sure that Python is the right "medium" for a functional/declarative style.
In more complex situations, it would be more appropriate to use object-oriented polymorphism (class support contains state rather than just functions)
ECMAScript Pattern Matching (if it ever lands) can clean up complex expression based data transformations considerably.
pattern matching would be awesome. I wanna have it everywhere
Sometimes the stars align and you get to "fake it" with a Bitwise OR (|):
clever, I had to stare at it for a few minutes to go through all the possibilities.
That's where the real beauty of a neatly syntaxed pattern matching expression could do a great deal to make it super obvious, what one wants to express with their code.
That's possibly because of lack of familiarity.
The Rust equivalent doesn't look that different to me:
in particular
In Erlang (and Elixir is similar) something like (again, assuming that the sides are sorted by length so that equal sides will always be adjacent)
or
ReScript (aka ReasonML; JavaScript flavored OCaml)
etc.
very likely.
And nice overview, of how different languages handle the same problem