Closed chiquitinxx closed 11 years ago
Final line is: assert callBackArray[0]() == 3
Problem was with empty expression in for. Never got before an emptyExpression, now just will return nothing. Javascript and groovy work same way with vars used in closures that are defined outside.
This code fails translating to javascipt:
def getCallBacks(){ def callBackArray = [] def i = 0; for(;i<3; i++){ callBackArray[i] = {return i;} } return callBackArray }
def callBackArray = getCallBacks() assert callBackArray[0]() == 3