Topic Overview and Lesson Plan

Greetings, Space Explorer! Today, we're going to dive into the realm of calling functions in Go. By the end of this lesson, you will have become proficient in function calls, transitive function calls, and returning multiple values from functions in Go.

Recall the Function Calling in Go

Just as you use a remote to switch on your television, calling a function in Go executes a set of commands. It's akin to issuing instructions to your spaceship's computer. Let's use a familiar scenario in space travel as an example: welcoming a new crew member. Here's how that could look:

In this example, we've instructed our spacecraft's computer to greet the newcomer, Astro Kid! Calling the greet function triggers the code block within that function.

Practical Explanation of Transitive Function Calling

In interstellar parlance, transitive function calling is tantamount to delegating spaceship tasks. You call one or multiple functions inside another function, assigning responsibility. Consider a scenario where we wish to fire up our spaceship's engine. Instead of handling the task directly, we delegate it to another function:

In this example, as we launch the spacecraft, we call to power up the engine of our spaceship. We then call to handle the post-startup operations of the engine. Thus, one function can certainly call another to complete a task.

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