Comparison

util/iterators.lua @ 7257:425bc672d60b

util.iterators: Don't replace var, as we should preserve var from the original iterator [luacheck]
author Matthew Wild <mwild1@gmail.com>
date Thu, 10 Mar 2016 17:48:53 +0000
parent 7186:9c3930bcbb72
child 7258:b8f60dd8e99a
comparison
equal deleted inserted replaced
7254:8aaae816cc7e 7257:425bc672d60b
152 return _range_iter, y, x-1; 152 return _range_iter, y, x-1;
153 end 153 end
154 154
155 -- Convert the values returned by an iterator to an array 155 -- Convert the values returned by an iterator to an array
156 function it.to_array(f, s, var) 156 function it.to_array(f, s, var)
157 local t, var = {}; 157 local t = {};
158 while true do 158 while true do
159 var = f(s, var); 159 var = f(s, var);
160 if var == nil then break; end 160 if var == nil then break; end
161 t_insert(t, var); 161 t_insert(t, var);
162 end 162 end