SplitWhereView

public struct SplitWhereView { /* private fields */ }

Lazy view over the segments of a string split at every code point matching a predicate. The matching characters are excluded from segments.

Examples

let view = "hello world".asSlice().split { (c) in c == Char(" ") }; view.first(); // Some("hello") view.count; // 2

Properties

public var count: Int64 { get }

Number of segments. O(n) — iterates once to count.

public var first: StringSlice? { get }

The first segment, or .None if empty.

public var isEmpty: Bool { get }

True when the source slice is empty.

public var last: StringSlice? { get }

The last segment, or .None if empty.

Initializers

public init(slice: StringSlice, where: consuming (Char) -> Bool)

Methods

public func collect() -> Array[StringSlice]

Collects all segments into an array.

ImplementsIterable

Associated Types

type Item = StringSlice
type TargetIterator = SplitWhereViewIterator

Methods

public func iter() -> SplitWhereViewIterator

ImplementsCloneable

Methods

public func clone() -> SplitWhereView

Defined in lang/std/text/views.ks