Sobes.tech
Junior — Senior

Finding the first object that matches the condition

livecode

Task condition

Conduct a code review: evaluate the correctness of the implemented logic and ensure the safe use of generators and parameters with default values.

def get_first_matching_object(condition, items=[]):
    gen = (elem for elem in items if condition(elem))
    if gen:
        result = gen[0]
        return result
    else:
        return None
Finding the first object that matches the condition… - sobes.tech