Search

Dark theme | Light theme

November 15, 2009

Groovy Goodness: Raising the Power of Numbers

The Groovy GDK adds the power() method to the Number class. The power() method has a shortcut operator: **.

assert 9 == 3**2
assert 27 == 3.power(3)
assert 16 == Math.pow(2, 4)  // Java way.