Skip to main content

toString

toString(value: T) : String for any type T.

The toString function converts any value to a string. Here are some examples.

toString([1, 2, 3]) -> "[1,2,3]"
toString(ipAddress("1.1.1.1")) -> "1.1.1.1"
toString(ipSubnet("1.1.1.1/1")) -> "1.1.1.1/1"
toString(macAddress("11:22:33:44:55:66")) -> "11:22:33:44:55:66"
toString(SubInterfaceVlan.VLAN\_ID(123)) -> "SubInterfaceVlan.VLAN\_ID(123)"
toString({ str: "string", bool: true, num: 1}) -> "{str:string, bool:true, num:1}"
toString(re`(?<name>\w+) (?<age:Number>\d+)`) -> "re`(?<name>\w+) (?<age:Number>\d+)`"

Although any value can be converted to a string, using toString will raise an error if the resulting string is considered too long, which is longer than 2000 characters. Use toStringTruncate to trucate the output instead raising an error.

See also

Types

Functions