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

fix: Correct logic in power function for zero exponent case #615

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Ready? Let’s get powered up!
public entry fun power(account: &signer, num1: u64, num2: u64) acquires Calculator {
let calculator = borrow_global_mut<Calculator>(signer::address_of(account));
if (num2 == 0) {
abort error::invalid_argument(0)
calculator.result = 1;
} else {
let i = 1;
calculator.result = num1;
Expand Down Expand Up @@ -172,4 +172,4 @@ Ready for the full code? We'll go through it in the next lesson! Stay tuned, roc

So there you have it, folks! Time to earn some brownie points. Try writing a loop to print all even numbers under 50. It's a fun challenge!

That's it for this lesson. In the next one, we'll compile all the calculator module code in one place, deploy it, and then interact with the frontend. Stay tuned for the grand finale!
That's it for this lesson. In the next one, we'll compile all the calculator module code in one place, deploy it, and then interact with the frontend. Stay tuned for the grand finale!