Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
arrays.index_to_int
arrays.index_to_int(array_of_inputs, index)
Descrição
Devolve o valor num determinado índice numa matriz como um número inteiro.
O índice é um valor inteiro que representa a posição de um elemento na matriz.
Por predefinição, o primeiro elemento de uma matriz tem um índice de 0 e o último elemento tem um índice de n-1, em que n é a dimensão da matriz.
A indexação negativa permite aceder a elementos da matriz relativamente ao fim da matriz. Por exemplo, um índice de -1 refere-se ao último elemento na matriz e um índice de -2 refere-se ao penúltimo elemento na matriz.
Tipos de dados de parâmetros
ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS
, INT
Tipo devolvido
INT
Exemplos de código
Exemplo 1
Esta chamada de função devolve 0 quando o valor no índice é uma string não numérica.
arrays.index_to_int(["str0", "str1", "str2"], 1) = 0
Exemplo 2
Esta função devolve o elemento no índice -1.
arrays.index_to_int(["44", "11", "22", "33"], 0-1) = 33
Exemplo 3
Devolve 0 para o elemento fora dos limites.
arrays.index_to_int(["44", "11", "22", "33"], 5) = 0
Exemplo 4
Esta função obtém o elemento da matriz de números de vírgula flutuante no índice 1.
arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1
Exemplo 5
Esta função obtém o elemento da matriz int no índice 0.
arrays.index_to_int([1, 2, 3], 0) = 1
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-08-20 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-20 UTC."],[[["\u003cp\u003e\u003ccode\u003earrays.index_to_int\u003c/code\u003e retrieves an element from an array at a specified index and returns it as an integer.\u003c/p\u003e\n"],["\u003cp\u003eThe function supports positive and negative indexing, with negative indices counting from the end of the array.\u003c/p\u003e\n"],["\u003cp\u003eIf the element at the specified index is a non-numeric string or the index is out of bounds, the function returns 0.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes two parameters, the first being the array (that can consist of string, integers or float values), and the second the index (an integer).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003earrays.index_to_int\u003c/code\u003e is supported in both Rules and Search.\u003c/p\u003e\n"]]],[],null,["### arrays.index_to_int\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n arrays.index_to_int(array_of_inputs, index)\n\n#### Description\n\nReturns the value at a given index in an array as an integer.\n\nThe index is an integer value which represents the position of an element in the array.\nBy default, the first element of an array has an index of 0, and the last element has an index of n-1, where n is the size of the array.\nNegative indexing allows accessing array elements relative to the end of the array. For example, an index of -1 refers to the last element in the array and an index of -2 refers to the second to last element in the array.\n\n#### Param data types\n\n`ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS`, `INT`\n\n#### Return type\n\n`INT`\n\n#### Code samples\n\n##### Example 1\n\nThis function call returns 0 when the value at the index is a non-numeric string. \n\n arrays.index_to_int([\"str0\", \"str1\", \"str2\"], 1) = 0\n\n##### Example 2\n\nThis function returns the element at index -1. \n\n arrays.index_to_int([\"44\", \"11\", \"22\", \"33\"], 0-1) = 33\n\n##### Example 3\n\nReturns 0 for the out-of-bounds element. \n\n arrays.index_to_int([\"44\", \"11\", \"22\", \"33\"], 5) = 0\n\n##### Example 4\n\nThis function fetches the element from the float array at index 1. \n\n arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1\n\n##### Example 5\n\nThis function fetches the element from the int array at index 0. \n\n arrays.index_to_int([1, 2, 3], 0) = 1"]]