News for hackers. Stuff that matters.
Re:Learn Dart in 15 Minutes by spankalee on Wednesday August 20, 2014 @03:21PM (#8204039)
Being explicit is great, but it doesn't prevent a library from defining it's own boolean coercion rules.

The Angular team, for instance, has defined toBool() (which they use in directives like ng-if) like this:

    bool toBool(x) {
      if (x is bool) return x;
      if (x is num) return x != 0;
      return false;
    }
It treats true and non-zero numbers as true, and everything else (including null) as false.

There are no comments on this comment yet.