Groovy
Retrieve the first object (index [0]) among all objects attached to this page and of a certain class
obj = doc.getObject('XWiki.XWikiComments')
com.xpn.xwiki.api.Object@4176a0ca
Retrieve all objects attached to this page and of a certain class and one of their properties
objs = doc.getObjects('XWiki.XWikiComments')
[com.xpn.xwiki.api.Object@63262540, com.xpn.xwiki.api.Object@5d57bf9a, com.xpn.xwiki.api.Object@2be44756, com.xpn.xwiki.api.Object@1807759d, com.xpn.xwiki.api.Object@11baa2be, com.xpn.xwiki.api.Object@74127109, com.xpn.xwiki.api.Object@66bb4167, com.xpn.xwiki.api.Object@fc305e2, com.xpn.xwiki.api.Object@4cb74083]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor