Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3390)

Unified Diff: sdk/lib/core/int.dart

Issue 988523002: Fix int.parse bug (dart2js version) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_number.dart ('k') | tests/corelib/double_parse_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/int.dart
diff --git a/sdk/lib/core/int.dart b/sdk/lib/core/int.dart
index 681b8e8815a4f0f166fbc22c51cf92de08d781a9..1d29a728f0399e2c16059fa1bb0ec26b69d29c8b 100644
--- a/sdk/lib/core/int.dart
+++ b/sdk/lib/core/int.dart
@@ -277,6 +277,13 @@ abstract class int extends num {
* value is used instead. If no [onError] is provided, a [FormatException]
* is thrown.
*
+ * The [onError] handler can be chosen to return `null`. This is preferable
+ * to to throwing and then immediately catching the [FormatException].
+ * Example:
+ *
+ * var value = int.parse(text, onError: (source) => null);
+ * if (value == null) ... handle the problem
+ *
* The [onError] function is only invoked if [source] is a [String]. It is
* not invoked if the [source] is, for example, `null`.
*/
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_number.dart ('k') | tests/corelib/double_parse_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698