Error in array/IndexOf
Collapse
X
-
The version is required in bug reports. https://forum.espocrm.com/forum/bug-...o-report-a-bug I move the post out of bug reports.Leave a comment:
-
prints "is null"Code:$index = array\indexOf(list(0, 1), 2); if ($index == null) { output\print('is null'); }Leave a comment:
-
Error in array/IndexOf
Hi.
When it doesn't find the value in the array it is not returning null. Is returning something else.
To test this I wrote this script
$testList = list(1,2,3,4,5,6);
$verify = 9;
$position = array\indexOf($testList, $verify);
$answer = 'unanswered';
ifThen($position > 0,
$answer = '>0');
ifThen($position == 0,
$answer = '0');
ifThen($position == null,
$answer = 'null');
ifThen($position == '',
$answer = 'nothing');
//********** INICIO LOG DE PRUEBAS
$tstDescription = null;
$tstName = "Test 1 ";
$tstDescription = string\concatenate(
' $position ', $position ,
' $verify ', $verify ,
' $answer ', $answer ,
' $testList ', array\join($testList, '-') ,
" ");
$tstLogId = record\create('LogPruebas',
'name', $tstName,
'description', $tstDescription);
//*********** FIN LOG DE PRUEBAS
I ran this script changing the line with the verify line to
$verify = 1;
$verify = 3;
$verify = 9;
And he output was:
So when $verify = 9; ir shows $position apparentely as a null, but when I ask if $position == null, it doesn't make $answer = 'null'
Tags: None

Leave a comment: