Core Function Bool

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> Bool( <expression> ) </pre> === Description === Returns the TRUE(1) or FALSE(0) representation of an expression === Parameters === ==== Expression ==== An expression t...")
 
m (1 revision)
 
(3 intermediate revisions by one user not shown)
Line 15: Line 15:
 
=== Return Value ===
 
=== Return Value ===
  
Success: Returns 1.
+
Success: Returns true.
  
Failure: Returns 0.
+
Failure: Returns false.
  
 
=== Remarks ===
 
=== Remarks ===
  
Sputnik doesn't have a BOOL type so it converts the expression to an Int64 then checks if its higher than zero then returns 1 or 0 depending on the result.
+
A bool in Sputnik can only be true or false (1 or 0 respectively).
 +
 
 +
When using == a bool will return true if he bool is true and the other value are 1 or higher example:
 +
 
 +
<pre>
 +
($a == true) // true as long as $a is higher than 0
 +
(true == $a) // false unless $a is 1
 +
</pre>
  
 
=== Example ===
 
=== Example ===

Latest revision as of 12:37, 14 June 2015

Bool( <expression> )

Contents

Description

Returns the TRUE(1) or FALSE(0) representation of an expression

Parameters

Expression

An expression to convert.

Return Value

Success: Returns true.

Failure: Returns false.

Remarks

A bool in Sputnik can only be true or false (1 or 0 respectively).

When using == a bool will return true if he bool is true and the other value are 1 or higher example:

($a == true) // true as long as $a is higher than 0
(true == $a) // false unless $a is 1

Example

$newValue = bool( $value );
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox