DEV Community

Discussion on: Using getters/setters as opposed to methods?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

I've had trouble with tsc (TypeScript compiler)'s get and set in the past, as well as I don't see much benefit.

Also the same case with Python, I see get and set as generally should be avoided, as they may obscure implementation.

The only real time I see benefit, is in Vue class components, where get will be translated to Vue getters, therefore cached.

Collapse
 
nombrekeff profile image
Keff

I tend to forget about them and don't use them often, can't see why. I was hoping somebody explained how they used them and why.