Learn Dart in 15 Minutes
learnxinyminutes.com
Learn Dart in 15 Minutes
1–10 of 42 posts
Re: Learn Dart in 15 Minutes
#2Re: Learn Dart in 15 Minutes
#3It occurred to me that HTML5 might have tightened up this rule, but it remains as before:
Re: Learn Dart in 15 Minutes
#4I love Dart, I think it's a great language. I hope that Google will start supporting it natively in Chrome.
http://www.chromestatus.com/features/6682831673622528
So in a few months we will have Google's VbScript available in Chrome.
Re: Learn Dart in 15 Minutes
#5One of the examples reminded me of some xml/html trivia I picked up a few years back -- attributes do not need to have double-quotes. (Yes, in practice you can leave out quotes altogether if the attribute has no spaces because browsers are tolerant, but the spec allows for single or double quotes, so if you're going to parse markup you need to allow for both.) It occurred to me that HTML5 might have tightened up this…
Re: Learn Dart in 15 Minutes
#6 // Boolean expressions need to resolve to either true or false, as no
// implicit conversions are supported.
I'm sure they have good reason for this, does anyone know of the rationale? I think I'd miss patterns like `if (arr.length) { ... }`Re: Learn Dart in 15 Minutes
#7This seems rather odd from example 14: // Boolean expressions need to resolve to either true or false, as no // implicit conversions are supported. I'm sure they have good reason for this, does anyone know of the rationale? I think I'd miss patterns like `if (arr.length) { ... }`
With implicit coercion, the programmer must mentally keep track of how values get coerced (are negative numbers truthy? are empty strings? empty lists? empty objects?). Different languages have different answers for all of these things. As a result, I prefer to always be explicit.
If you've never seen the WAT?[1] talk, I suggest watching it. It has some great examples of type coercion gone wrong in Ruby and JS.
Re: Learn Dart in 15 Minutes
#8This seems rather odd from example 14: // Boolean expressions need to resolve to either true or false, as no // implicit conversions are supported. I'm sure they have good reason for this, does anyone know of the rationale? I think I'd miss patterns like `if (arr.length) { ... }`
At least for this particular example, dart supports an 'isNotEmpty' property on all iterables[0], so it'd just be this:
if (arr.isNotEmpty) { ... }
The core libraries support a lot of useful properties like that.[0] https://api.dartlang.org/apidocs/channels/stable/dartdoc-vie...
Re: Learn Dart in 15 Minutes
#9This seems rather odd from example 14: // Boolean expressions need to resolve to either true or false, as no // implicit conversions are supported. I'm sure they have good reason for this, does anyone know of the rationale? I think I'd miss patterns like `if (arr.length) { ... }`
Boolean conversion maps any object o into a boolean. Boolean conversion is defined by the function application
(bool v){
assert(v != null);
return identical(v, true);
}(o)Re: Learn Dart in 15 Minutes
#10This seems rather odd from example 14: // Boolean expressions need to resolve to either true or false, as no // implicit conversions are supported. I'm sure they have good reason for this, does anyone know of the rationale? I think I'd miss patterns like `if (arr.length) { ... }`
> I think I'd miss patterns like `if (arr.length) { ... }` At least for this particular example, dart supports an 'isNotEmpty' property on all iterables[0], so it'd just be this: if (arr.isNotEmpty) { ... } The core libraries support a lot of useful properties like that. [0] https://api.dartlang.org/apidocs/channels/stable/dartdoc-vie...