Posts

Showing posts with the label unary

Bob Lee Course Part 8 (lectures 12 to 15)

Image
Next day, next lecture! I literally have 25 minutes now so I will see if I get to a natural end point... Extensions Now I know about these already. Extensions are a way of adding more code to different types. E.g. to Int, I could add a function or something that gives more usability. I can also extend custom types e.g. structs and classes. *Udemy course not loading properly. Going to have to delay start time for now.  Start Time - 15:39  *I only have around 15 minutes for now so will have to continue the entry for later. OK, so the issue here is that you CANNOT have STORED properties in extensions. Right, so in this case, the description property is computed. So this is a cool example of using a new property (computed!) for Int. Squared! So that is everything we can do with extensions. Most of these are later as you can see. So far, that's good. I had to race through some of the using init...

Arithmetic Operators; Assignment and Comparison; Operator Precedence; Unary Operators

So I am coming to the end of the recap of my 'Swift Basics' course. Once I've finished that, I should feel pretty secure with the essentials. The next task after this will be to go over the other courses I have completed. Realistically, by this time next week, I should be ready to continue with learning 'new' information! Arithmetic Operators There is some technical mathematical information about operands. We now move on to the four main operations - add, subtract, multiply and divide. The other function that can be used is the remainder operator (% is used). E.g. 9 % 4 would give 1. let height = 12 let width = 10 let area = height * width Simple stuff for using multiplication, in this case.  The next part is dividing the area by 10.764, to have the answer in metres. However, this is a double. The most logical thing to do is changing height to 12.0 and width to 10.0. Or, you can declare height and width as doubles, using the syntax of the ...