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@7fe5282a
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@68bade59, com.xpn.xwiki.api.Object@445bdac6, com.xpn.xwiki.api.Object@6a782039, com.xpn.xwiki.api.Object@748bb4ca, com.xpn.xwiki.api.Object@a758d, com.xpn.xwiki.api.Object@2eab7c00, com.xpn.xwiki.api.Object@7c59fbef, com.xpn.xwiki.api.Object@77ab47b0, com.xpn.xwiki.api.Object@defb131]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor