2

This code works even though contactID is not in scope at the time of the query. Can anyone explain what is going on here?

String query = 'SELECT Id FROM Contact WHERE ';
if (true) {
    String contactID = '0031C00002s6r7aQAA';
    query+='Id=:contactID';
}
List<Contact> cons = (List<Contact>)Database.query(query);
System.assertEquals(1,cons.size(),'1 contact');
0