コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
arrays.index_to_float
arrays.index_to_float(array, index)
説明
配列の指定されたインデックスにある要素を返します。そのインデックスの要素が float として返されます。
インデックスは、配列内の要素の位置を表す整数値です。デフォルトでは、配列の最初の要素のインデックスは 0、最後の要素のインデックスは n-1 です。ここで、n は配列のサイズです。負のインデックスを使用すると、配列の末尾を基準にして配列要素にアクセスできます。たとえば、インデックス -1 は配列の最後の要素を参照し、インデックス -2 は配列の最後から 2 番目の要素を参照します。
パラメータのデータ型
ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS
、INT
戻り値の型
FLOAT
コードサンプル
例 1
次の例では、浮動小数点数の配列からインデックス 1 の要素を取得します。
arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 1) // 2.1
例 2
次の例では、浮動小数点数の配列からインデックス -1 の要素を取得します。
arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 0-1) // 4.6
例 3
次の例では、配列のサイズより大きいインデックスの要素を取得します。
arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 6) // 0.0
例 4
次の例では、空の配列から要素を取得します。
arrays.index_to_float([], 0) // 0.0
例 5
次の例では、文字列配列のインデックス 1 の要素を取得します。
arrays.index_to_float(["1.2", "3.3", "2.4"], 1) // 3.3
例 6
次の例では、整数の配列からインデックス 2 の要素を取得します。
arrays.index_to_float([1, 3, 2], 2) // 2.0
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-29 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-29 UTC。"],[[["\u003cp\u003e\u003ccode\u003earrays.index_to_float\u003c/code\u003e retrieves an element from an array at a specified index and returns it as a float.\u003c/p\u003e\n"],["\u003cp\u003eThe function supports positive and negative indexing, where negative indices count backward from the end of the array.\u003c/p\u003e\n"],["\u003cp\u003eIt can handle arrays of strings, integers, or floats, and converts the element at the index to a float.\u003c/p\u003e\n"],["\u003cp\u003eIf the index is out of bounds or the array is empty, \u003ccode\u003earrays.index_to_float\u003c/code\u003e returns 0.0.\u003c/p\u003e\n"],["\u003cp\u003eThe function is available in both Rules and Search functionalities.\u003c/p\u003e\n"]]],[],null,["### arrays.index_to_float\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n arrays.index_to_float(array, index)\n\n#### Description\n\nReturns the element at the given index of an array. The element at that index is returned as a float.\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`FLOAT`\n\n#### Code samples\n\n##### Example 1\n\nThe following example fetches an element at index 1 from an array of floats. \n\n arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 1) // 2.1\n\n##### Example 2\n\nThe following example fetches an element at index -1 from an array of floats. \n\n arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 0-1) // 4.6\n\n##### Example 3\n\nThe following example fetches an element for an index greater than the size of the array. \n\n arrays.index_to_float([1.2, 2.1, 3.5, 4.6], 6) // 0.0\n\n##### Example 4\n\nThe following example fetches an element from an empty array. \n\n arrays.index_to_float([], 0) // 0.0\n\n##### Example 5\n\nThe following example fetches an element at index 1 from a string array. \n\n arrays.index_to_float([\"1.2\", \"3.3\", \"2.4\"], 1) // 3.3\n\n##### Example 6\n\nThe following example fetches an element at index 2 from an array of integers. \n\n arrays.index_to_float([1, 3, 2], 2) // 2.0"]]