Skip to content

String Format

The string::format function formats a string by replacing placeholders with corresponding values. It is similar to the printf function in C and other similar functions in other programming languages.

Syntax

string::format(<template>, <value1>, <value2>, ...)

Parameters

  • template: The template string containing format verbs, ie. %s and %d.
  • value1, value2, ...: The values to insert into the placeholders in the template.

Returns

  • String: The formatted string.

Example

Try it out below!
string::format("Hello, %s!", "world")

This function is useful for creating dynamic strings with variable content.