XCTAssert syntax error with array shorthand expression and method call

Viewed 1394

So I am diving into unit tests with XCTest, and have run into a little problem.

When I write an XCTAssert statement with a shorthand array declaration and method call inside, a syntax error is spat out in Xcode:

XCTAssert([self hasStrings:@[ @"foo", @"bar" ]]);

In the Xcode compile errors:

Expected identifier or '('

However, if I add more brackets around the expression, it will work:

XCTAssert(([self hasStrings:@[ @"foo", @"bar" ]]));

Is this something to do with some of my syntax not being allowed to be passed into a macro? (Assuming that XCTAssert is a macro)

1 Answers
Related