Posts

Showing posts with the label return

Ray Wenderlich Course Part 9 (up to lesson 79)

Image
So back to the situation of not having much time to write! Am starting this entry now and will continue it on the train. Once I've got functionals and optionals done then that will do for now. Again, I'm going at x 1.5 speed as it's mostly recap. It will be the challenges to really test my mettle! I'm also not going to type examples along - again, it's mostly recap! Functions So just to sum up, you can have no parameters and have code within the curly braces e.g. something to print, or you can have values within the parameters. Within the parameters, you can specify the values or just name the parameter and the type. You can use the _ for an unnamed parameter. The return option -> means you use the return keyword rather than a print function. A little bit in the Q&A from Ray about the distinction between functions and methods: In the old days of programming before Object-Oriented Programming was invented, everyone used to only use functions (usin...

Functions (part 2)

Continuing with functions! My plan in the next hour is to have completed this Functions course. That means there is only one more full one, then I'll be back to the one that I was working on the last time I gave Swift a major push! Anyway, the next few videos are the more fiddly bits about Functions... Naming Conventions Pasan starts by an English grammar link - the use of prepositions - what connect the nouns. They also occur in prepositional phrase e.g. along the river, next to the tree etc. Applying this to functions, we want functions to read as grammatically correct phrases - in the code. Pasan explains that these are confusing but the convention of using these - the naming conventions - is something to get used to. Argument Labels func remove(havingValue: String ) {          print (havingValue) } In this example, it's not very clear in terms of the parameters. So you can have an external and a local name. By adding a keyword after 'h...