0

I am not sure how to return a struct that is inside an array of structs. This is my code:

contract StudentsInfoTracker{ Student[] students; struct Student{ string name; address ethAddress; uint numberInClass; uint[] marks; } function getStudent(uint) public view returns(string memory name, address ethAddress, uint numberInClass, uint[] memory marks){ return(students[uint].name, students[uint].ethAddress, students[uint].numberInClass, students[uint].marks); } 

I need to return the student given the uint index. I know I can't return a complete struct but I can try to retrieve its data. Anyway I get this error:

TypeError: Type type(uint256) is not implicitly convertible to expected type uint256.

1 Answer 1

2

You forgot to name your variable. You only gave it a type. Try this:

function getStudent(uint id) ... { return (students[id].name, students[id].ethAddress, ...); } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.