educative.io

`outer` struct not being dereferenced when assigning a value to its fields

In previous sections we have had to dereference a struct created with new() since it was a pointer, to be able to assign values to its fields. Looks like in this lesson that principle does not apply, why is this?

Hi @Alvaro_Fernandez, Thanks for reaching out to us.
In the previous lesson, we learned the following different methods:

  • struct as a value type
  • struct as a pointer (with and without dereference operator)
  • struct as a literal

So, it’s totally your choice to use any of them that’s why in the given example it’s not mandatory to use the same method which has been used in the previous example.

Hope it will help :slight_smile: