Introduction

Hello, Space Explorer! Today, we’re diving into an essential topic using Go: managing data using structs and slices. To practice this concept, we will build a simple Student Management System. We will create a struct that stores students and their grades. This hands-on approach will guide us in understanding how structs and slices can be effectively utilized in real-world applications. Excited? Awesome, let's dive in!

Introducing Methods to Implement

To achieve our goal, we need to implement three primary methods (i.e. receiver functions) within our student management system:

  1. (sm *StudentManager) addStudent(name string, grade int): This function allows us to add a new student and their grade to our list. If the student is already on the list, their grade will be updated.
  2. (sm *StudentManager) getGrade(name string) (int, bool): This function retrieves the grade for a student given their name. If the student is not found, it returns 0 and false.
  3. (sm *StudentManager) removeStudent(name string) bool: This function removes a student from the list by their name. It returns true if the student was successfully removed, and false if the student does not exist.

Does that sound straightforward? Fantastic, let's break it down step by step.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal