Trailing Closures in Oxygene and C#

It is a nice feature, but you are show only the “new” Syntax
But where is the “old”?
You ask:
Doesn’t this look much nicer than the equivalent with an anonymous method?
but where can I see the old ? For me it is not even clear what this feature try to solve… :slight_smile:

Well, the old one would be just a regular anonymous method:

dispatch_async(myQueue, method begin
  PerformSlowWorkInBackground;
end);

after reading the swift docs, I see, but you should show the differents in the blog.

1 Like

Same for me.

@mh: as you said in the blog that this was needed for something new, what problem is solved by this - what can I do with the new syntax that I couldn’t do with the old?
As for me it looks like the word ‘method’ and one comma is dropped and the closing parentis is moved to that place. I looks absolutely nice, but I do not understand what we are gaining here.

As mentioned in the blog post, that new thing is a larger feature we’re working on that’s not quite ready to talk about, this is just one of a few syntax features that (in addition to being generally useful) will make what we’re planning there look nicer.

Nothing, it’s purely aesthetic. By definition, any use of these feature, you could write using a regular anonymous method. Instead of having nested method begin ... end inside the parameters of a method call, you have a begin/end block (or curly braces, in C#) that look and feel like a regular language block. ie in the above example dispatch_async now feels like a if/then or any other language construct.

1 Like

Completely clear :smile:

1 Like