Can someone try to explain the attached code? My code for the Day 47 challenge works, but I don't understand the static func portion of my struct for Equatable:
and I don't understand how the comparison works inside the DetailsView:
Trying to work through this challenge, I had to resort to copyinmg someone's code but don't like that I don't understand it.
Please try to explain how this is working.
When you conform a data type to
To conform to
you are saing that 2
Here in the
you are looping through the list of
Thank you @roosterboy,
So, theoretically, is the code not great?
For example, the .title could be the same for several
I really appreciate the help. This one has me really confused and I want to ensure I understand before I move on.
You should keep
And you are correct!
That depends. What does it mean for two
Once you figure out what makes two
You can actually have the compiler synthesize
@IceMonster has questions about Equatable.
He received many correct answers from our regulars.
I hope I can add some clarification without further confusing Ice?
Take a step away from your solution, and think about how you compare two items. Start with Integers. How can you tell if one integer is the same as another? That's trivial!
How can you determine if one string is the same as another? Also pretty trivial!
But how do you determine if two songs are the same?
Examine the two songs! Are they, in fact, the same song? What would be appropriate rules to declare two songs are the same?
If you just compare song titles, you'll have problems with the song named "Try" (Nelly Furtado, John Mayer, Pink). If you compare song title and group, you'll have issues when groups release dance versions, extended versions, instrumental versions, and possible greatest hits versions.
Instead, to compare two of your Song
It may seem strange to you, but the "name" of that function is
And the reason it's a static function? The method belongs to the
SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.