Skip to content

ProtoString enumerateLines() Method

Seth Clydesdale edited this page Jun 2, 2015 · 2 revisions

<< Back to Miscellaneous Methods

Examples

Numbering each newline.

'Coffee\nCream\nSugar'.enumerateLines();

// returns the following string
`1. Coffee
2. Cream
3. Sugar`

Passing true as the parameter will start the listing at 0.

'Coffee\nCream\nSugar'.enumerateLines(true);

// returns the following string
`0. Coffee
1. Cream
2. Sugar`

Description

The enumerateLines method numbers out each line by placing a number at the beginning of newlines. The listing starts at 1, however, if specified it can start at 0.

Syntax

String.enumerateLines(zero);

Parameters

Parameter Description
zero A boolean value that specifies the listing should be zero-based. If set to true the first line will be numbered 0. Defaults to listing the first line as 1 if left undefined.
Clone this wiki locally