6 ms·
I don't understand why public fields need the underscore prefix. Aren't all fields public by default? Why do you need to add a prefix to "hide" public fields?
by ihuman 8y ago
I don't understand why public fields need the underscore prefix. Aren't all fields public by default? Why do you need to add a prefix to "hide" public fields?
- mikewhy 8y agoThey don't, that's just the example they chose. Prefixing variables / functions with the underscore has long been a signal for "this is private" in languages that don't provide the functionality.
- sjroot 8y agoThis is true, but the whole point of this article is to introduce a new way of handling private class members.
- sjroot 8y agoI think the idea is to distinguish them from class getter functions? I don't really understand it either.