Posts

Showing posts with the label self

Object-Oriented Swift - Complex Data Structures

I am now onto the next course! This is the last full course I need to recap/redo before continuing with the one I got to before. All of the skills I have built up over the past week or so have really made me feel positive about Swift. The next lot of videos are about 'structures' - bundling together a number of variables and values. It is going to be a step up.... Introduction to Structs The first example Pasan gives is vaguely familiar - it's about using coordinates for shooting towers for a game. The number of values needed means that we would need to create a struct. Creating a separate value for each of the x and y axes are useless. Creating a tuple would be better as the x and y values are linked together.  let coordinate1: (x: Int , y: Int ) = ( 0 , 0 ) This is fine but is going to be quite limited. Instead we are going to create a custom struct. As struct can define variables or constants, which are called stored properties. No value needs to be ass...