Last answered:

20 Apr 2022

Posted on:

19 Apr 2022


Resolved: confusion about the init function

if I made a mistake by entering the age variable first instead of the name it's going to assign the age as a name, how can you further control something like that

1 answers ( 1 marked as helpful)
Posted on:

20 Apr 2022


Dear Doaa,

Thank you for your question!

When declaring an object the way Giles does in the lesson, you have to provide the arguments in the order they are implemented. That is, first, you need to provide the name, then the age. This can be circumvented by explicitly typing the name of the parameter before assigning it a value. This is, in fact, the preferable way of doing it as it avoids any confusion.
Please, study the code snippet below which demonstrates this.
Hope this helps!

Kind regards,
365 Hristina

Submit an answer