Why I cannot set Copy.destinationDir property?

I cannot understand something in configuring tasks.
For example I create task
task myCopy(type: Copy) {
from(“myDir”) {
rename("$jarName", “$jarFinalName”)
}
destinationDir("$rootDir/publish/")
}

because I see property destinationDir on this page
https://docs.gradle.org/3.3/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:destinationDir

But I get an error saying

Could not find method destinationDir() for arguments [publish] on task ‘:prepareJar’ of type org.gradle.api.tasks.Copy.

If I change it to ‘into’ then all is well.
Why I have to use ‘into’ instead of property ‘destinationDir’ described in docs?

setDestinationDir requires a File object and you are passing a GString. It is better to use into as it takes an Object and allows for lazy-evaluation.

thanks for helping me