Closed ultraq closed 4 years ago
OK, I've found there are some tricks/caveats with this. If I'm still dealing with hard primitives, like those coming out of other Java code and not my own Groovy code, then it's still subject to the usual Java behaviour. So I can't just go removing all the bit masks and call it a day - gotta either test or make sure if doesn't break anything.
Done in all the places I thought it safe!
Because Groovy uses autoboxing behind the scenes for all of its primitive types, we don't fall into the trap in vanilla Java where going from a small primitive to a bigger one fills in the bits w/ 1s, eg:
But in Groovy:
This should make all the bit/byte operations that I had to mask in Java unnecessary! 🎉 Man Groovy is the best 😁