|
|
|
|
|
by Quekid5
2320 days ago
|
|
Some reasoning would be nice. I'm guessing this is mostly a nicety to paper over the fact that 'if' is not an expression in JS, so you have to do things like var foo;
if (something) {
foo = <SomeComponent.../>;
} else {
foo = <OtherComponent .../>;
}
<Container>
{foo}
</Container>
whereas if JS has if-expressions, you'd just say <Container>
{
if (something) {
<SomeComponent.../>;
} else {
<OtherComponent .../>;
}
}
</Container>
(or similar). From that perspective it seems like a nice little thing to have. |
|
Dart also has spread operators and for-expressions to make writing "UI with code" much easier. It's fresh to see how language design choices are being made more by pragmatic ones (for Dart it's the fact that it's primarily being used for Flutter to make UIs) instead of ideological ones (One might claim that "if" should be a pure expression following the tradition from functional languages like ML, but that also has its own set of problems in a language designer's perspective)
https://medium.com/dartlang/making-dart-a-better-language-fo...