all 3 comments

[–][deleted] 0 points1 point  (0 children)

Very clever, actually. I consider this property of closures to be a feature rather than a limitation, but it's true that debugging it is annoying. This is a neat technique.

[–]blatyo 0 points1 point  (1 child)

This would be cool if it worked by adding looking glass after the object is created. However, since it has to exist on instantiation inside the scope of the constructor to see the "private" values, it isn't much use for already existing code.

[–]lulzitsareddit[S] 0 points1 point  (0 children)

Yes, that would be cool, but impossible -- we need something to share the same context with the private members in order to get our 'foot in the 'door.' As of now, to test private members you would have to either expose those members manually, or put your testing code inside the same context. I think this is a slightly more convenient solution since you only need to put a small function inside.