3 ms·
I know very well that I can use inner mutability to work around that restriction, that doesn't change the fact that it is a workaround, nothing more.
by sgift 10y ago
I know very well that I can use inner mutability to work around that restriction, that doesn't change the fact that it is a workaround, nothing more.
- twblalock 10y agoIt's not a workaround. It was designed to work that way on purpose. The people who developed this feature could have easily prevented programmers from using any variables outside of the stream, final or not, but they chose not to because they wanted to allow programmers to use final variables in this way. Furthermore, it does not cause you to lose "all the power of real closures" like you said it does. All you lose is the ability to use a closure around non-final variables, which is a trivial drawback in any use case I've ever come across. You lose only a little bit of the power of closures.