| OLD | NEW |
| 1 part of utilslib; | |
| 2 | |
| 3 // 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 |
| 4 // 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 |
| 5 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 6 | 4 |
| 7 /** | 5 /** |
| 8 * General purpose string manipulation utilities. | 6 * General purpose string manipulation utilities. |
| 9 */ | 7 */ |
| 10 class StringUtils { | 8 class StringUtils { |
| 11 /** | 9 /** |
| 12 * 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]. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 25 return (str == null) ? ifNull : int.parse(str); | 23 return (str == null) ? ifNull : int.parse(str); |
| 26 } | 24 } |
| 27 | 25 |
| 28 /** Parse bool to a double, and handle null intelligently */ | 26 /** Parse bool to a double, and handle null intelligently */ |
| 29 // TODO(jacobr): corelib should have a boolean parsing method | 27 // TODO(jacobr): corelib should have a boolean parsing method |
| 30 static bool parseBool(String str, [bool ifNull = null]) { | 28 static bool parseBool(String str, [bool ifNull = null]) { |
| 31 assert(str == null || str == 'true' || str == 'false'); | 29 assert(str == null || str == 'true' || str == 'false'); |
| 32 return (str == null) ? ifNull : (str == 'true'); | 30 return (str == null) ? ifNull : (str == 'true'); |
| 33 } | 31 } |
| 34 } | 32 } |
| OLD | NEW |