Checking Toolchain in cpp-library - example in docs doesn't work

Has an example for adding compiler options:

tasks.withType(CppCompile).configureEach {
    // Define a preprocessor macro for every binary
    macros.put("NDEBUG", null)

    // Define a compiler options
    compilerArgs.add '-W3'

    // Define toolchain-specific compiler options
    compilerArgs.addAll { toolChain ->
        if (toolChain in [ Gcc, Clang ]) {
            return ['-O2', '-fno-access-control']
        } else if (toolChain in VisualCpp) {
            return ['/Zi']
        return []

However with Gradle 7.2 the line: if (toolChain in [ Gcc, Clang ]) { does not match for me. I had to change this to: if (toolChain in Gcc || toolChain in Clang) {

Is this a bug in the docs or in Gradle?