How to set limits on an integer

I have got this integer.

static var energyObj : int = 5;

If i press a button, it subtracts one from the integer, and if i walk into a collider it adds one to the integer. Now how would i set a limit on this integer, so that it won’t go lower than 0 and it won’t go higher than 5.

sounds perfectly like mathf.clamp

but in documentation it says clamp is for float, so possibly you could use something like this:

static var energyObj : float = 5;

function Update()
{
energyObj = Mathf.Clamp(energyObj,0,5);
}

Edit: Mathf.Clamp is fine for int’s too, just scroll down a bit further in doc