OxL Reference

init String.new

Ends the building and returns the immutable str; the builder is consumed.

Example:

oxl✓ checked in CI
fn main() io {
  var s = String.new()
  s.push("done")
  let text = s.freeze()
  print(text)
}
Output
done

Appends one character.

Example:

oxl✓ checked in CI
fn main() io {
  var s = String.new()
  s.pushChar('x')
  s.pushChar('y')
  print(s.freeze())
}
Output
xy

Appends a string.

Example:

oxl✓ checked in CI
fn main() io {
  var s = String.new()
  s.push("a")
  s.push("bc")
  print(s.freeze())
}
Output
abc

Length in bytes (UTF-8).

Example:

oxl✓ checked in CI
fn main() io {
  var s = String.new()
  s.push("héllo")
  print("{s.len()}")
}
Output
6

An empty string builder.

Example:

oxl✓ checked in CI
fn main() io {
  var s = String.new()
  s.push("ab")
  print(s.freeze())
}
Output
ab
pub(api) init new() -> Self

Since. 1.0.0-beta

Returns

Self

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/collections.oxl:1175

See also