API Reference › Text › Text.ends_with
method

Text.ends_with

Text.ends_with(s, suffix) -> bool

Returns true when s ends with suffix, comparing the tail of the string over the suffix's length. If the suffix is longer than the string it simply returns false. Use it to detect file types by extension, recognize a trailing marker, or validate that input closes as expected.

Parameters

sthe string to test
suffixthe trailing substring to look for

Example

program IsImage {
  var filename: string = "hero.png"

  handler Classify phase Update {
    let png = Text.ends_with(filename, ".png")   # true
  }
}
← All symbols