Documentation Language: Swift

Method

clear()

Clears the buffer and resets the writer state.

func clear()

Discussion

This removes all accumulated text and resets the writer to its initial state (at line start). The indentation level is preserved.

Example

await writer.writeLine("Line 1")
await writer.clear()

let content = await writer.getContent()
print(content)  // "" (empty)

await writer.writeLine("New start")
let newContent = await writer.getContent()
print(newContent)  // "New start\n"