Group Group Group Group Group Group Group Group Group

Programming in Swift · Challenge: Structures | Ray Wenderlich


This is a companion discussion topic for the original entry at

Hello, thank you for this challenge.
I have a couple of questions:

  1. would it be plain wrong to create a Pizza struct with toppings declared as an [String] to let more freedom?
  2. I have tried this for the overlapping method but I am not sure why this is not consistently good:
    func willOverlap(with restaurant: Restaurant, to location: Location) -> Bool { return self.willDeliver(to: location) == restaurant.willDeliver(to: location) && self.willDeliver(to: location) == true }

Thank you

  1. Not necessarily! But if you know at compile time exactly what all of your options are going to be, for a type, then an enumeration will be easier to work with.

That goes for most everything in Swift, actually. In the second part of Saving Data in iOS, we go over how your Swift types can be represented by formats that are very much akin to working with only Swift Strings, Dictionaries, and Arrays. But making use of Swift’s type system makes for a much better experience.

  1. Your code simplifies to:
self.willDeliver(to: location) && restaurant.willDeliver(to: location)

Whether both restaurants will deliver to a certain location might be useful information to know, but it is different information than whether their delivery areas overlap.

1 Like

Thank you so much!

All the best for the holiday season!!

1 Like

How to understand what exactly do you expect to use in tasks?
Because for example:
“Write a struct that represents a pizza. Include toppings, size and any other option you’d want.”

So I did like that:
struct pizza {
let topping: String
let size: Int
Can I use this one as well for task? This is structure and it includes topping and size let as requested.

1 Like

If you don’t want any other options for your pizza, that’ll do just fine! It meets the criteria.

We used an enumeration for toppings because of knowing at compile time exactly what the options would be – enumerations are a perfect match for that.


There seems to be some missing tutorials. The tutorial for structures along with its respective challenge are extremely complex to understand it feels like Ive missed some tutorials in preparation for this - which I didn’t.

Please provide some supporting materials or at least references to other recommended trainings to better understand those concepts. I might be slower than others, but from my perspective, the tutorial is extremely complex and doesn’t help simplify the concept.


Any chance I might be getting a response some time soon?


Hello @fouadghandour,

We’re aware that devoting more time to structures will help out a lot of folks, and we’ll be doing that in this year’s course/learning path update.

In the meantime, I recommend:

  1. Asking any questions you might have, here, whose answers would help clarify anything in the episode for you. (Then we’ll know better where people are struggling, so we can target those area in future updates.)
  2. Reading the official documentation. There are a lot of resources out there, but this is a common one every Swift programmer ought to be familiar with, for all topics.
  3. Searching the web for more info on any topic of confusion you have. This is a forever-ongoing process for all of us. We at want to be creating the best learning material, but we can’t cover everything. If there’s some really good information that you find elsewhere which you think we should incorporate into one of our courses, we’d always love to hear about that!


this is my second comment I am writing. I am really not a comment-guy, as it were, but I feel I ought to provide some insight as a professional teacher.

  1. The spoken language, in particular with videos, must match what is being illustrated. It is no good to come out with statements like: “You can use self here, but you don’t need to” or “I don’t know, if you have come across nested types or not” without providing thorough explanation. This only creates frustration for the learner, because it is expert discourse. The learner for a lack of knowledge is not part of that discourse group and hence lack out his depth. To give you an analogy, it is as if I were to teach children about American history but in the exam ask questions about English history. So if you were to talk about aspects, which might lead you off on a tangent, I am afraid you would need to provide illustration and, even better, practice material. As it is you are confusing unnecessarily the learner.

  2. You guys need to work out what your customer segment is. Are you providing lessons to newbies or to trained computer experts. Because it does make a difference. Whereas the first videos were easy to follow for me, you really changed the narrative in these videos. It is as if you were talking to somebody completely different (see the statements I am referring to above). As a paying customer I find this frustrating and your comments for other users, experiencing similar difficulties, to browse the internet for answers is not helpful, given a) that Swif is in its 5th incarnation and hence the documents and sites often may refer to older versions without making it explicitly clear, b) is RW not trying to position itself as the best online teacher for Swift?

Didactics and corporate strategy require a conscientious approach. As it is I find it wanting.