0

What's happening here in the code and why is my loop not working? And one more thing, should I remove all the warnings from my code before deploying?

function sub(uint n, uint a) external pure returns(uint) {
    for(uint i=1; i<100; i++) {
        uint b;
        b += n+a;
        return b;
    }
}

enter image description here

2
  • What exactly you want to achieve with your sub function? Commented Jun 5 at 15:18
  • Please, use text to show source code. It will be much easier to test.
    – Ismael
    Commented Jun 9 at 5:43

1 Answer 1

2
  1. You are using 'return' inside a loop, so the code will return and stop the loop on the first iteration.

  2. You can keep the warnings; they won't stop your code from working. However, it's better to always fix all warnings.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.