obj.registerMethod(runtime.newNativeMethod("returns a list of all groups captured in this match. if a group is not matched it will be nil in the list. the actual match text is the first element in the list.", new TypeCheckingNativeMethod.WithNoArguments("asList", obj) {
@Override
public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
List<Object> groups = new ArrayList<Object>();
MatchResult mr = getMatchResult(on);
int len = mr.groupCount();
for(int i=0;i<len;i++) {
if(mr.isCaptured(i)) {
groups.add(context.runtime.newText(mr.group(i)));
} else {
groups.add(context.runtime.nil);