ChardScript Booleans
Booleans represent one of two values: true or false.
Boolean Values
In programming you often need to know if an expression is true or false.
You can evaluate any expression in ChardScript, and get one of two answers, 1 or 0, 1 is true and 0 is false.
When you compare two values, the expression is evaluated and ChardScript returns the Boolean answer:
Example
echo(10 > 9)
echo(10 == 9)
echo(10 < 9)When you run a condition in an if statement, ChardScript returns true or false:
Example
Print a message based on whether the condition is true or false:
call a = 200
call b = 33
if b > a then
echo("b is greater than a")
else
echo("b is not greater than a")
endFunctions can Return a Boolean
You can create functions that returns a Boolean Value:
Example
Print the answer of a function:
You can execute code based on the Boolean answer of a function:
Example
Print "YES!" if the function returns true, otherwise print "NO!":
ChardScript also has many built-in functions that return a boolean value, likeisnumber(), isstring(),islist()andisgroup()functions.
Example
Check if an object is an number or not:
Example
Check if an object is an string or not:
Example
Check if an object is an list or not:
Example
Check if an object is an function or not:
Last updated