So I did this thing when he asked us to initialize and it seems to have worked.
Is this good? Plus, why did it work if I failed to identify the length of the array?
With braced initialization for arrays, you don’t need to specify a length as you’re automatically providing all of its data at the time of initialization. The compiler will take care of the size automatically.
As for whether it is good, it’s certainly useful when you know the exact values you’re going to load into an array at the time of initialization and of compilation. Making it const also saves you from making unwarranted changes if you don’t intend to have those values change. Using the method from the course (the bottom image) would primarily be companied with a for-loop to initialize each element, which you’ll see more of in Dapper Dasher if not already.
Thank you for the clear explanation.
The course is great and really shines when he stops and lets me try to guess how to do it before moving on. I have trouble sticking things in my head if I don’t ask enough questions to understand why when I can. The little discrepancies between his way and my way at these points are where some of the best learning is.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.