Now this is a GCC feature extension also present in Clang of which we had not previously been aware:
Ever since I found out that a GCC C extension causes a code block to return a value if you enclose it in round brackets, I’ve been using it in my code. What do you think?
1 self.bounds = ({<br /> CGRect bounds = self.bounds;<br /> bounds.size.height = self.currentYPosition + SHEETINSETY;<br /> bounds;<br />});
Cool beans. Improves succinctness and reduces declaration scopes, both of which are bug-avoiding Good Things™. Plus there’s the extra bonus of confusing your coworkers by checking in code using extensions they’re probably not aware of either, which is always good for a chuckle. Or “cackling with unholy glee”, as other people see it. Whichever.
h/t: @steipete!
UPDATE:
Hey, you can use this to call blocks inline at their definition too!