+ 1

Why not just use a1.name?

Refering to the first example in this lesson. Simply accessing the object's variable or attribute through . seems simpler and faster, and I fail to visualize how using equals is better..

15th Apr 2017, 4:28 AM
The Guy
The Guy - avatar
7 Respostas
+ 6
Please clarify with example
15th Apr 2017, 5:49 AM
Meharban Singh
Meharban Singh - avatar
+ 5
asker @ace
15th Apr 2017, 5:43 PM
Meharban Singh
Meharban Singh - avatar
+ 1
@ace that's exactly how it should be (even the overuse of getter/setter part) how is this controversial? the only thing not aligning good with reality is the overuse getter/setter part. however that's mostly due to (imo) wrong definition of unit testing.
15th Apr 2017, 6:01 AM
Petja Boigk
Petja Boigk - avatar
+ 1
Thanks Ace! Great answer. My question mainly revolved around the futility of using equals, and as I'm guessing from your answer, I wasn't wrong. But you're right, in most big projects, private variables with user-defined Getters and Setters are preferable. It is situational though. My answer is here; equals isn't the only way (except for strings in certain cases). Thanks!
15th Apr 2017, 4:40 PM
The Guy
The Guy - avatar