Playground
Input:
for (const char of 'foo') {
print(char);
}
Current Result:
function __TS__Iterator(iterable)
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
return function()
local result = iterator:next()
if not result.done then
return result.value
else
return nil
end
end
else
local i = 0
return function()
i = i + 1
return iterable[i]
end
end
end
for char in __TS__Iterator("foo") do
print(char)
end
Expected Result:
function __TS__Iterator(iterable)
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
return function()
local result = iterator:next()
if not result.done then
return result.value
else
return nil
end
end
elseif type(iterable) == "string" then
local i = 0
return function()
i = i + 1
return string.sub(iterable, i, i)
end
else
local i = 0
return function()
i = i + 1
return iterable[i]
end
end
end
for char in __TS__Iterator("foo") do
print(char)
end
Playground
Input:
Current Result:
Expected Result: