ludic/docs/language/text/text-ends_with.md

818 B

id name category kind tokens sig tip order ns member
text-ends_with Text.ends_with text namespace-method Text.ends_with Text.ends_with(s, suffix) -> bool Whether a string ends with a given suffix. 4 Text ends_with

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:

  • s — the string to test
  • suffix — the trailing substring to look for
program IsImage {
  let filename: string = "hero.png"

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