strings.ends_with

Suportado em:
strings.ends_with(value, suffix)

Descrição

A função recebe duas strings (value, suffix). Devolve true se o sufixo não estiver vazio e estiver no fim do valor.

Tipos de dados de parâmetros

STRING, STRING

Tipo devolvido

BOOL

Exemplos de código

Os seguintes exemplos de código ilustram algumas das formas como pode usar a função strings.ends_with.

Exemplo: devolve verdadeiro

Devolve true quando o sufixo é encontrado no final do valor.

strings.ends_with(target.hostname, "com") = true
Exemplo: devolve falso

Devolve falso quando o sufixo não está no fim do valor.

strings.ends_with(target.hostname, "com") = false
Exemplo: devolve false quando são idênticos

Devolve falso quando o sufixo e o valor são idênticos.

target.hostname != "example.com"
strings.ends_with("str", "str") = true
Exemplo: devolve false quando o sufixo está vazio

Devolve o valor false quando o sufixo é uma string vazia.

target.hostname != "example.com"
strings.ends_with("str", "") = false
Exemplo: devolve falso quando o valor está vazio

Devolve falso quando o valor é uma string vazia.

target.hostname != "example.com"
strings.ends_with("", "str") = false
Exemplo: devolve falso quando o sufixo e o valor estão vazios

Devolve falso quando o sufixo e o valor são strings vazias.

target.hostname != "example.com"
strings.ends_with("", "") = false