Chapter 10 Question

When adding the user parameters for the EntryRoutes in chapter 10, I noticed that the getEntries function was the only one that had a (() -> Void) -> Void form.

When I checked the included code for the book, I noticed that the func getEntries was the same () -> Void form as the rest of the routes.

Is this an oversight? I guess I’m a bit confused as to what this is doing. I realize that it is an escaping closure, but all other functions that have the first form seem to be in the JournalEntry struct.

When would it be appropriate in Kitura to use each of the forms?

@seabaylea Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi @beefycode

The two forms:

func getEntries(completion: @escaping ([JournalEntry]?, RequestError?) -> Void) -> Void {


func getEntries(completion: @escaping ([JournalEntry]?, RequestError?) -> Void) {

are actually identical - if you don’t specify the second -> Void then the compiler will infer it.

It is a confusing disparity in the book though - we should choose one of the other and be consistent for the next update.

Do you feel one form or the other makes more sense?

Thanks for the reply,

It did seem to me that the form didn’t really make any difference, but I wanted to see if I was missing something.

For what I prefer, I suppose I’m a typical lazy coder and would likely use the single -> Void form myself :slightly_smiling_face: