Skip to content

Commit

Permalink
simplify join to use Logger::write_iter
Browse files Browse the repository at this point in the history
  • Loading branch information
hackwaly committed Dec 9, 2024
1 parent 2dc847d commit 74a68f7
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions builtin/iter.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -785,21 +785,7 @@ pub fn collect[T](self : Iter[T]) -> Array[T] {
/// Collects the elements of the iterator into a string.
pub fn join(self : Iter[String], separator~ : String = "") -> String {
let buf = StringBuilder::new()
if separator == "" {
for str in self {
buf.write_string(str)
}
} else {
let mut first = true
for str in self {
if first {
first = false
} else {
buf.write_string(separator)
}
buf.write_string(str)
}
}
(buf : Logger).write_iter(self, prefix="", suffix="", sep=separator)
buf.to_string()
}

Expand Down

0 comments on commit 74a68f7

Please sign in to comment.