Need help with rules

Say I have 100 parameters, all of different types. How do I get them into a task from the outside? Rules were supposed to do this but I see no examples that make it clear how the references get from outside a task to a place where they can be used by a task.

tasks.addRule("Pattern: ping<ID>") { String taskName ->
   if (taskName.startsWith("ping")) {
      task(taskName) << {
         println "Pinging: " + (taskName - 'ping')
      }
   }
}

Above is the example given in the documentation here:
https://docs.gradle.org/current/userguide/more_about_tasks.html#N10F07
I know that this is configuring a task:
task {…stuff…}
…and this is defining a task:
task << {…stuff…}
…but I’ve not been able to come up with a way to get data into one so that I can use it.

What have you already tried? Can you show us how you create those parameters and how they should be used in your task?