Details(细节)
Description
In the initStudent1() function example, the comment says // assign a copy of student. However, in Solidity, assigning a state variable to a local variable with the storage data location creates a reference (or pointer), not a copy.
Using the word "copy" might confuse beginners into thinking it acts like a memory assignment.
Location
- File:
06_ArrayAndStruct/readme.md
- (Please also check the corresponding
.sol source file if the code is duplicated there).
Current Code
function initStudent1() external{
Student storage _student = student; // assign a copy of student
_student.id = 11;
_student.score = 100;
}
Suggested Fix
Update the comment to accurately reflect that a reference is being created:
function initStudent1() external{
Student storage _student = student; // creates a storage reference to student
_student.id = 11;
_student.score = 100;
}
Are you willing to submit a PR?(你愿意提交PR吗?)
Details(细节)
Description
In the
initStudent1()function example, the comment says// assign a copy of student. However, in Solidity, assigning a state variable to a local variable with thestoragedata location creates a reference (or pointer), not a copy.Using the word "copy" might confuse beginners into thinking it acts like a
memoryassignment.Location
06_ArrayAndStruct/readme.md.solsource file if the code is duplicated there).Current Code
Suggested Fix
Update the comment to accurately reflect that a reference is being created:
Are you willing to submit a PR?(你愿意提交PR吗?)