I sometimes come across a chunk of PeopleCode that requires a variable be compared to a list of values — like the IN operator in SQL:


If &code = "ABCD" Or &code = "HIJK" Or &code = "OPQR" Then
   ...

If the condition needs to be checked multiple times within the code and the list changes, there will be some effort required to update the code.

A better coding approach is to use an array and its Find method:


Local array of string &list;
 
&list = CreateArray("ABCD", "HIJK", "OPQR");
...
If &list.Find(&code) > 0 Then
   ...

If the list of values changes, only the array will need to be updated.