Group Group Group Group Group Group Group Group Group

Programming in Swift · Structures | Ray Wenderlich


This is a companion discussion topic for the original entry at


Very difficult to understand…lost myself after 5 minutes of lesson.


Hi! I’m sorry to hear you’re having trouble with this one. Can you tell us what you had trouble understanding?


For example that moment:
restaraunts[0].willDeliver(to: Location(x:1, y: 2))

There are some many “location” words in this topic , so I can’t clearly understand the right connection: step by step.


@ollybess Please let us know what you don’t understand exactly in the above line of code. Thank you!



  1. restaurants[0] means we’re taking 1st element:
    Restaurant(location: Location(x: 0,y: 0), deliverDistance: 3)
  2. For this element we’re executing func willDeliver…
    and after that I’m lost, what values and objects exectly we take and what happen next


@ollybess Do you have issues with what the willDeliver(to:) method does exactly?


that’s correct
too many “location” inside that method


@ollybess The willDeliver(to:) method is related to the getDistance( _: ) one. Do you understand what that one does?


I understand what we get using that method, but did’nt clear understand how.
and how they work together (willDeliver and getDistance)


Very hard to follow this tutorial. Swift tutorials were okay to follow until it got to closures and structs. Should start with simpler examples and then build up. Keep in mind people who are watching this tutorial aren’t programmers already. Also, for the harder topics such as the ones mentioned, break the videos down into shorter ones.


@mostafa.gazar Thank you for your feedback - much appreciated! Could you please let us know what you found hard to follow exactly?



I agree with mostafa.gazar the example is difficult to follow. Additionally I did not get what is “extension”


Hi! As mentioned in the video, extensions allow you to add code to a struct outside of its original definition. So all of the code we wrote in the extension, you could move back into the struct’s definition. You’ll see extensions used a lot as an organizational tool in other courses and in tutorials on the site.