5 ms·
That's actually a really clever (yet simple) design. Have other languages done this before? Now I cannot "unsee" that concept. Why isn't if/else an expression
by Someone1234 7y ago
That's actually a really clever (yet simple) design. Have other languages done this before?
Now I cannot "unsee" that concept. Why isn't if/else an expression in other languages that just yields a value?! That's a powerful idea.
- cesarb 7y ago> Have other languages done this before? LISP. For a more recent example, Rust.
- int_19h 7y agoIt's very common for languages to adopt an everything-is-an-expression concept, and then make if/else the conditional operator.
- nepeckman 7y agoNim does this as well. Almost any block statement (including creating a new scope with `block`) can be put on the right hand side of an assignment. Whatever value is returned from the block is the result of the expression. All lisp inspired, of course, but with a Pythonic syntax.
- virtualwhys 7y ago> Have other languages done this before? Well, yeah, Scala obviously, the primary language from which Kotlin drew inspiration for its syntax and features.
- Drakar1903 7y agoI wonder why people don't frame Kotlin as the middleman that takes the good parts of both Java and Scala.
- barryhoodlum 7y agoOcaml does this too.
- umanwizard 7y agoRust has this, as well as some other nice ML-inspired[0] features, like structured bindings. That’s one thing I like about Rust: it fuses functional and imperative styles very naturally. [0] “ML” here meaning the family of languages including SML and OCaml, which inspired (to varying degrees) Haskell, Rust, some parts of modern C++, and surely others. Not “machine learning”.