Lasso Soft Inc. > Home

[ boolean ]

Type

[Boolean] is a primitive built-in data type used to represent the value true or false. Literal true and false are produced with  the words 'true' or 'false' (no quotes, not case-sensitive).

Calling the boolean() method with no parameters will return false. Calling the method with any other single parameter will return either true or false depending on the following:

The following values are considered to be false:

  • The empty string ''
  • The integer zero 0 or decimal zero 0.0
  • [null] or [void]
  • Boolean false

Every other value is considered true.

A value is implicitly converted to true or false when used as the single operand to the 'if' or 'while' constructs.

  • Syntax
  • Methods
  • Traits
boolean('Value')

local(x = boolean('Value'))
Has methods:
Examples
  • Beginner

To explicitly convert a value to boolean:

Use the [boolean] method. The following example converts the string 'false' to boolean, resulting in False.

Code

boolean('false')

Result

false

To determine if a value passed in a GET or POST request was 0 or greater than zero:

Code

local(mylocal = integer(web_request->param('status')))
if(#mylocal) => {^
    'value was true'
else
    'value was false'
^}

Result

http request: ?status=1
-> true

http request: ?status=0
-> false

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2014 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft