Module 2 Lesson 2 (arrays challenge)

Hi!

Could someone please explain the purpose of the Card structure? Couldn’t you just put that variables (“number” and “suit”) in the ContentView structure somehow?

Best regards,

@zpr

Welcome to the community.

In cases where you have simple data, as in this case, you could have two arrays in parallel which use the same index value but the thrust of these tutorials is to get people used to structures for dealing with complex data.

As the data for one occurrence of an item becomes more complex, insofar as describing the properties for each instance, it becomes abundantly clear that a struct is far more easy to deal with rather than multiple arrays being used in parallel.

Ok, thanks!