Converts a bool to a float
Device + Agent
Float — 1.0 for true
or 0.0 for false
This method returns either 1.0 or 0.0 depending on whether the target bool is true
or false
.
local anArray = [1, 2, 3, 4, 5, 6]; | |
foreach (index, value in anArray) { | |
// Convert any even numbers to floats | |
local b = (value % 2 == 0); | |
if (b) anArray[index] = value * b.tofloat(); | |
} | |
// anArray equals [1, 2.0, 3, 4.0, 5, 6.0] |