I am new to Grails and I tried to work with an Array. I can't believe that I don't get it working, but 开发者_JAVA技巧its really like this. I researched now for an hour, but I'm somehow too stupid! ;)
I've got this class:
package com.test
class SimuCacheService {
    static transactional = false
    def questionList = []
    def getQuestionList() {
        return questionList
    }
}
From antoher class I want to access the questionList and for example simply add an element
package com.test
class SimulatorController {
    def startSimu = {
        SimuCacheService cacheService = new SimuCacheService();
        def questionList = cacheService.getQuestionList();
        params.eins.each{i->
            System.out.println(i);
            **questionList.add(i);**
        }
        System.out.println(questionList[0]);
        System.out.println(questionList[1]);
    }
}
thats not working, because "add" doesn't exist. I tried with questionList[i], this did not work either. Its so annoying, I just want to use that array! Can anybody help me please? :-)
this is not working either:
questionList[questionList.length-1] = i;
:-(
try:
package com.test
class SimuCacheService {
    static transactional = false
    List questionList = []
}
all other your code can stay the same
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论