Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for loop closure variable life cycle #299

Closed
yanghuan opened this issue May 12, 2020 · 0 comments
Closed

for loop closure variable life cycle #299

yanghuan opened this issue May 12, 2020 · 0 comments

Comments

@yanghuan
Copy link
Owner

for (var i = 0; i <= Template.MultipleHarms.Length; i++)
{
   Hero.CreateTimer(effectTime, () =>
    {
       OnResultSkillEffect(i, targets);
    });
 }

lua

 for i = 0, #this.Template.MultipleHarms do
   this.Hero:CreateTimer(effectTime, function ()
     OnResultSkillEffect(this, i, targets)
   end)
end

this code has logical differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant