Group Group Group Group Group Group Group Group Group

Programming in Swift · Structures | Ray Wenderlich


#1

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5994-programming-in-swift/lessons/39

#2

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


#3

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


#4

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.


#5

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


#6

Ok

  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

#7

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


#8

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


#9

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


#10

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


#11

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.


#12

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


#13

Hello!

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


#14

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.