Skip navigation
ANNOUNCEMENT: community.oracle.com is currently Read only due to planned upgrade until 29-Sep-2020 9:30 AM Pacific Time. Any changes made during Read only mode will be lost and will need to be re-entered when the application is back read/write.

The final version of Scala 2.10 was released on January 4, 2013. Martin Christensen, a visiting scholar in our department, and myself have been playing with some of the new features, and I'll be blogging about some of our discoveries in my copious spare time.

Today, I'll show you how to write a simple macro in Scala. You may have seen macros in C, such as #define swap(x, y) { int temp = x; x = y; y = temp; }

C macros are just text substitutions. If you callswap(first, last), the result is