toBool toBool

根據其型別,將引數值轉換為布林值。

  • 從字串:嘗試將字串值轉換為布林值,如果字串值為「true」,則從「true」,否則為false
  • 從數值:如果數值不等於0,則為true;否則為false

類別

轉換

函式語法

toBool(<parameter>)

參數

  • 小數
  • 布林值
  • 字串
  • 整數

簽章與傳回的型別

toBool(<decimal>)

toBool(<boolean>)

toBool(<string>)

toBool(<integer>)

傳回布林值。

範例

toBool("true")

toBool(1)

傳回true。

toBool("this is not a boolean")

傳回false。

recommendation-more-help
4f4a00c1-77c9-4eee-84df-bbe6206c3ab9