On Lucee 4.5.1.003 I have this function where LineArray is an array of LineItem objects.
public function getLineItemDetailsById(required numeric id){
this.LineArray.each(function(i){
if(i.Id == id){
return i;
}
});
}
The function returns null even if there is a match. If I add a var to hold the found object, the var is returned.
public function getLineItemDetailsById(required numeric id){
var found = '';
this.LineArray.each(function(i){
if(i.Id == id){
found = i;
//return i;
}
});
return found;
}
Am I doing something wrong expecting array.each to return i or am I misunderstanding how array.each works?
Edit: To be clear, the second function does return the found object.