forcePositive property

T get forcePositive

Returns the value unsigned, regardless of its original sign.

If the value is already positive, it returns the value itself. If the value is negative, it returns the negation of the value.

Example:

var num = -5;
var result = num.forcePositive; // result is 5

Implementation

T get forcePositive => this < 0 ? -this as T : this;