types.String.endswith
Returns whether str ends with suffix.
The binding carries no declaration string, so the VM cannot report parameter names. The names above are from this page; the types and attributes still come from the VM. The VM also cannot tell an optional parameter from a variadic tail here, so read the brackets and any trailing
... from the prose below, not from the signature.Parameters
suffix | string | the suffix to look for |
Return value
true when the last suffix.len() bytes of str equal suffix, false otherwise. An empty suffix always matches; a suffix longer than str cannot match.
Notes
Takes exactly one argument. Same implementation as string.endswith; see the Notes on types.String.strip for how the two forms differ only in their reported attributes, not their behavior.
The comparison is a raw byte compare; there is no case-insensitive form.
Example
println("\"hello world\".endswith(\"world\") =", "hello world".endswith("world"))
println("\"hello world\".endswith(\"hello\") =", "hello world".endswith("hello"))Output:
"hello world".endswith("world") = true
"hello world".endswith("hello") = falseSee also
startswith | Returns whether str begins with prefix. |
endswith | Returns whether str ends with suffix. |
| string | class index |