set_has_element()

使用 版本 下拉選單切換服務。 了解更多關於導航的資訊。
Apply to: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel

判斷指定的集合是否包含指定的專案。

語法

set_has_element( 集合,價值)

深入瞭解 語法慣例。

參數

姓名 類型 必要 描述
set dynamic ✔️ 要搜尋的輸入陣列。
value ✔️ 要搜尋的值。 值的類型應該是long、int、、doubledatetime、、timespan、decimal、string、 guid或 bool。

傳回

true 或 false 取決於值是否存在於陣列中。

範例

print arr=dynamic(["this", "is", "an", "example"]) 
| project Result=set_has_element(arr, "example")

輸出

結果
true

使用 array_index_of(arr, value) 來尋找值存在於陣列中的位置。 這兩個函式都同樣高效能。