What is wrong on extracting the index value from Set

groovy

Solution

The error message sais it all: the method you are calling `listset.getAt()` is not implemented.

You can fix this by converting the set into array or list, eg: `listset.toList()[0]` or `listset.toArray()[0]`.

That said I'm not sure if doing this makes much sense, because set doesn't guarantee order of the elements in it by definition. If you need to process all keys of a map, use iterator instead.

Problem

This is my piece of code. ``` def http = [100 : 'CONTINUE',200 : 'OK',400 : 'BAD REQUEST'] def listset = http.keySet() log.info listset[0] ``` i would expect here, as `listset[0]= 100`. But Getting.. ``` groovy.lang.MissingMethodException: No signature of method: java.util.HashMap$KeySet.getAt() is applicable for argument types: (java.lang.Integer) values: [0] Possible solutions: getAt(java.lang.String), getAt(java.lang.String), putAt(java.lang.String, java.lang.Object), wait(), toSet(), sort() error at line: 32 ``` What is wrong in this..??

Original source