reverse<A> function
- Bounded<
A> bounded
Returns a Bounded<A>
with its bounds reversed.
The top
of the original bounded object becomes the bottom
of the
reversed one and vice versa.
Example:
void main() {
// Create a bounded type for integers in the range of 1 to 10
final boundedIntegers = Bounded<int>((x, y) => x.compareTo(y));
boundedIntegers.top = 10;
boundedIntegers.bottom = 1;
// Reverse the bounds
final reversedBoundedIntegers = reverse(boundedIntegers);
print(reversedBoundedIntegers.top); // Output: 1 (The bottom of the original)
print(reversedBoundedIntegers.bottom); // Output: 10 (The top of the original)
}
Implementation
Bounded<A> reverse<A>(Bounded<A> bounded) {
return _ReversedBounded<A>(bounded);
}