Tuesday, September 18, 2012

Breaking Change: parseInt to become int.parse

Yesterday, Lasse Nielsen, an engineer on the Dart team, wrote to the Dart mailing list about a new breaking change coming to the Dart core libraries. The parseInt and parseDouble from dart:math will be replaced by int.parse and double.parse, respectively.

Lasse writes:

Greetings all.

We are removing parseInt and parseDouble from the dart:math library, and making them static methods called "parse" on the int and double classes.
The original reason, from long ago, for putting them in Math was that int and double were interfaces, and couldn't contain static methods. Now that we are converting all interfaces to abstract classes, we will move those functions where they belong.

The dart:math parseInt/parseDouble functions will still work, but they will be removed in about a week.

The functions now have documentation too! Please do report if it is confusing or misleading in any way.

Cheers
/L


A good discussion then followed with suggestions for creating named constructors, or if parse should be moved to num. You can follow along at the Dart mailing list for more. Thanks for trying Dart!