Search

Dark theme | Light theme

January 5, 2010

Groovy Goodness: Make a Number Absolute

In Groovy we can make a number absolute with the abs() method. This method is added to the Number class by Groovy.

assert 42 == (-42).abs()
assert 43.21 == (-43.21).abs()