Tag Archives: Code

Learning Swift Programming – Day 1

The Swift Programming LanguageOkay, well technically it’s not Day 1 (but i wan’t to recap my learnings once a day and this is the first post).  I’ve been working through the “The Swift Programming Language” for about a week now. I’m on page 18 of the book and I’ve written ~287 lines of code in the playground. It’s a ton of fun to go through but I find myself not exactly understanding everything.

Specifically this example below.  I understand that is sorting and that reversing the $number will reverse the sort but I have no idea why?  The books says:

“You can refer to parameters by number instead of by name—this approach is especially useful in very short closures. A closure passed as the last argument to a function can appear immediately after the parentheses.” 1

Reading that above, and writing the code below I still don’t understand what $0 and $1 are referring to? They are a stand-in for the variables but what variables exactly? I understand that I must be passing the array of numbers and ordering them based on one being more than or less than the next. I also get in the side bar that to complete the first and second function it took 9 iterations. I’m assuming then that the sort function must sort an array… and that maybe it’s running until the function returns false so until $1 is no longer > than $2. But I’m totally guessing here. Any help understanding this would be appreciated.

let mySort = sort([1,5,3,12,2]) { $1 > $0 } // no idea what this is doing?  I'm assuming it is sorting the array of numbers.
mySort

let theSort = sort([1,5,3,12,2]) { $0 > $1 } // no idea what this is doing?  I'm assuming it is sorting the array of numbers.
theSort

  1. Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks.https://itun.es/us/jEUH0.l 

Getting back into coding….

sql azure logo

So I’ve been reading a lot on happiness lately and I seem to see signs everywhere pointing me towards doing something more motivating, more enjoyable, something that makes the day go by a lot faster.  One of the things I used to do all the time and thought I was really good at was problem solving using MIcrosoft SQL – writing code.  The days would fly by and I was super energized.  I don’t feel that way anymore and it’s sad.  I want to get back into it.  Life is too short to be spending time doing something you don’t enjoy.

So, too my point.  I’m thinking about spinning up on Microsoft SQL Azure.  Re-learning my old skill with a new twist (Azure is Microsoft’s cloud computing offering).  So over the next few week’s I’ll be putting together a plan to sharpen my skills a bit and get back in the technical groove as time permits.  At least that’s the plan for now.  🙂