Why can't I use a getter and setter in a class. #91
Unanswered
raybags-dev
asked this question in
FAQ
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, probably not a good question but I figured maybe you could have some insight on this issue . I would appreciate your opinion.
Q_1: Given this code:
Its a simple class that saves a person's name, age with methods to get age and name and also delete the person object entirely.
It works perfectly with these methords:
Why is it that I cant use the
Setter
andGetter
key words to get and set parameters for my methods in the class like this:Q_2: Given this code:
Given the above code snippet, when calling when calling the get name and get age methods, i do something like this:
const p = new Person('x', 60);
p.get_name()
ORp.get_age()
wouldn't it be nice if I could call this method as
p.get_name
ORp.get_age
I think it would be neater.
Anything you can suggest would be appreciated. Thanks guys.
Beta Was this translation helpful? Give feedback.
All reactions