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@5bc3cee
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@3b39e83, com.xpn.xwiki.api.Object@56bac5b, com.xpn.xwiki.api.Object@60008d24, com.xpn.xwiki.api.Object@443267b9, com.xpn.xwiki.api.Object@4937c5a9, com.xpn.xwiki.api.Object@6c91ffcc, com.xpn.xwiki.api.Object@6530e1c3, com.xpn.xwiki.api.Object@6c35fd1b, com.xpn.xwiki.api.Object@4c7c2f1d]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor