top | item 33719600 (no title) Casperin | 3 years ago I don't necessarily agree that Python overall is difficult to read, but one thing that seems to get my every time is the foo = x if y else z discuss order hn newest jasonjmcghee|3 years ago I see where you're coming from.Many languages support the ternary operator, where it would be: foo = y ? x : z Which "feels better" but I think that's because I learned ternaries first.Some languages like Rust and Kotlin do support assignment of an if statement like foo = if (y) { x } else { z } And I think that's a good step, as it doesn't need to introduce new syntax, just allows assignment of "blocks" Casperin|3 years ago Yes. It requires that `if else` can be used as expressions, which for some reason in most languages that can not.In the beginning of doing Rust I was missing the ternary operator, but now I couldn't care less. foo = if y { x } else { y } Works well :-)
jasonjmcghee|3 years ago I see where you're coming from.Many languages support the ternary operator, where it would be: foo = y ? x : z Which "feels better" but I think that's because I learned ternaries first.Some languages like Rust and Kotlin do support assignment of an if statement like foo = if (y) { x } else { z } And I think that's a good step, as it doesn't need to introduce new syntax, just allows assignment of "blocks" Casperin|3 years ago Yes. It requires that `if else` can be used as expressions, which for some reason in most languages that can not.In the beginning of doing Rust I was missing the ternary operator, but now I couldn't care less. foo = if y { x } else { y } Works well :-)
Casperin|3 years ago Yes. It requires that `if else` can be used as expressions, which for some reason in most languages that can not.In the beginning of doing Rust I was missing the ternary operator, but now I couldn't care less. foo = if y { x } else { y } Works well :-)
jasonjmcghee|3 years ago
Many languages support the ternary operator, where it would be:
Which "feels better" but I think that's because I learned ternaries first.Some languages like Rust and Kotlin do support assignment of an if statement like
And I think that's a good step, as it doesn't need to introduce new syntax, just allows assignment of "blocks"Casperin|3 years ago
In the beginning of doing Rust I was missing the ternary operator, but now I couldn't care less.
Works well :-)