Retrieve a Task’s Results

Learn to use Task.async, which has the property to return a struct containing the executed task’s result.

The Task.async/1 task

To retrieve the result of a function, we use Task.async/1. It returns a %Task{} struct which we can assign to a variable for later use. We can give it a try in IEx like this:

This is the executable command:

Get hands-on with 1200+ tech skills courses.