| OLD | NEW |
| 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 part of html_common; | 5 part of html_common; |
| 6 | 6 |
| 7 class Lists { | 7 class Lists { |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Returns the index in the array [a] of the given [element], starting | 10 * Returns the index in the array [a] of the given [element], starting |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 return accumulator; | 67 return accumulator; |
| 68 } | 68 } |
| 69 | 69 |
| 70 static String join(List<Object> list, [String separator]) { | 70 static String join(List<Object> list, [String separator]) { |
| 71 if (list.isEmpty) return ""; | 71 if (list.isEmpty) return ""; |
| 72 if (list.length == 1) return "${list[0]}"; | 72 if (list.length == 1) return "${list[0]}"; |
| 73 StringBuffer buffer = new StringBuffer(); | 73 StringBuffer buffer = new StringBuffer(); |
| 74 if (separator == null || separator == "") { | 74 if (separator == null || separator == "") { |
| 75 for (int i = 0; i < list.length; i++) { | 75 for (int i = 0; i < list.length; i++) { |
| 76 buffer.add("${list[i]}"); | 76 buffer.write("${list[i]}"); |
| 77 } | 77 } |
| 78 } else { | 78 } else { |
| 79 buffer.add("${list[0]}"); | 79 buffer.write("${list[0]}"); |
| 80 for (int i = 1; i < list.length; i++) { | 80 for (int i = 1; i < list.length; i++) { |
| 81 buffer.add(separator); | 81 buffer.write(separator); |
| 82 buffer.add("${list[i]}"); | 82 buffer.write("${list[i]}"); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 return buffer.toString(); | 85 return buffer.toString(); |
| 86 } | 86 } |
| 87 } | 87 } |
| OLD | NEW |