Native C++: define multiple external libraries with a loop

I have a native project with multiple references to external libraries (on Linux):

model {
  components { ... }
  repositories {
    libs(PrebuiltLibraries) {
      m {
        binaries.withType(SharedLibraryBinary) {
          sharedLibraryFile = file("/usr/lib64/libm.so")
        }
      }

      rt {
        binaries.withType(SharedLibraryBinary) {
          sharedLibraryFile = file("/usr/lib64/librt.so")
        }
      }
    }
  }
}

I’m sure I can define m { ... } and rt { ... } with a loop because they follow the same template:

  ["m", "rt"].each {
    ??? {
      binaries.withType(SharedLibraryBinary) {
        sharedLibraryFile = file("/usr/lib64/lib${it}.so")
      }
    }
  }

How can I do so?

Simply with a groovy g-string
Use “$it” instead of your ‘???’

Thanks, it worked! Actually I had tried it { ... } before I posted this question, only to get an error No signature of method. What is the difference between it and "$it" here? I thought they were equivalent.