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

Side by Side Diff: samples/swarm/swarm_ui_lib/util/StringUtils.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * General purpose string manipulation utilities. 6 * General purpose string manipulation utilities.
7 */ 7 */
8 class StringUtils { 8 class StringUtils {
9 /** 9 /**
10 * Returns either [str], or if [str] is null, the value of [defaultStr]. 10 * Returns either [str], or if [str] is null, the value of [defaultStr].
11 */ 11 */
12 static String defaultString(String str, [String defaultStr='']) { 12 static String defaultString(String str, [String defaultStr='']) {
13 return str === null ? defaultStr : str; 13 return str == null ? defaultStr : str;
14 } 14 }
15 15
16 /** Parse string to a double, and handle null intelligently */ 16 /** Parse string to a double, and handle null intelligently */
17 static double parseDouble(String str, [double ifNull = null]) { 17 static double parseDouble(String str, [double ifNull = null]) {
18 return (str == null) ? ifNull : double.parse(str); 18 return (str == null) ? ifNull : double.parse(str);
19 } 19 }
20 20
21 /** Parse string to a int, and handle null intelligently */ 21 /** Parse string to a int, and handle null intelligently */
22 static int parseInt(String str, [int ifNull = null]) { 22 static int parseInt(String str, [int ifNull = null]) {
23 return (str == null) ? ifNull : int.parse(str); 23 return (str == null) ? ifNull : int.parse(str);
24 } 24 }
25 25
26 /** Parse bool to a double, and handle null intelligently */ 26 /** Parse bool to a double, and handle null intelligently */
27 // TODO(jacobr): corelib should have a boolean parsing method 27 // TODO(jacobr): corelib should have a boolean parsing method
28 static bool parseBool(String str, [bool ifNull = null]) { 28 static bool parseBool(String str, [bool ifNull = null]) {
29 assert(str == null || str == 'true' || str == 'false'); 29 assert(str == null || str == 'true' || str == 'false');
30 return (str == null) ? ifNull : (str == 'true'); 30 return (str == null) ? ifNull : (str == 'true');
31 } 31 }
32 } 32 }
OLDNEW
« no previous file with comments | « samples/swarm/swarm_ui_lib/touch/TouchHandler.dart ('k') | samples/swarm/swarm_ui_lib/util/Uri.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698