//SPDX-License-Identifier:GPX-3.0
pragma solidity >=0.7.0 <0.9.0;
contract sol {
struct student {
string name;
uint256 ID;
string grade;
}
bytes32[] private student_Address;
mapping(bytes32=>student) private studentMap;
uint256 private index = 0;
function createNewStudent(string memory _name, uint256 _id, string memory _grade) public {
student_Address.push(keccak256(abi.encodePacked(index)));
studentMap[student_Address[index]] = student(_name, _id, _grade);
index++;
}
function getStudentInfo(uint256 num) public view returns (bytes32, student memory) {
return (student_Address[num], studentMap[num]); // line 21
}
}
where I have a problem is line 21 :return (student_Address[num], studentMap[num]);
The error message is: TypeError: Type uint256 is not implicitly convertible to expected type bytes32
but I don't understand why there's type error.
Because return type of student_Address[num] is bytes32, and I properly declared it. And uint256 num is just a index.