Functions as arguments

When i typed code to xcode that this book offered to me i got nothing…Simply compiler did not give me any result(bugs,errors,nil none of them). I provide the code for you:

As you can see xcode gives me nothing.
Then i’ve changed this code a bit and i got this:

Here i changed If block made it after declaring function biuldRoads and everything works fine.
Anyone can explain why this happened? I suugest that,when we call again buildRoads function from last sentence i mean this code: stopLights = townPlanByAddingLightsToExistingLights(4, stopLights), so compiler simply cannot get function because of if block.As we know if statement need to be checked to run code.But in my edited version of code i declared firstly function and thats why it worked i think. Am i right?