Documentation Language: Swift

Function

startsWith(_:_:)

Checks if a string starts with a specified prefix.

func startsWith(_ string: any EcoreValue, _ prefix: any EcoreValue) throws -> EBoolean

Parameters

string

The string to test

prefix

The prefix to check for

Return Value

true if the string starts with the prefix, false otherwise

Discussion

The startsWith operation tests whether the string begins with the specified prefix string.

Examples

let text = "Hello World" as EString
let startsWithHello = try startsWith(text, "Hello")  // Result: true
let startsWithWorld = try startsWith(text, "World")  // Result: false