variable and function with same name
1
Name:
Anonymous
2010-09-18 22:50
Suppose I have a private boolean variable named isCool.
What should the setter and getter functions for this variable be called? setIsCool()? getIsCool() is not as nice sounding as simply isCool().
I would make the variable public, but how do I know with absolute certainty that I won't need to do some additional stuff every time before setting or getting, which would want a function to handle that without breaking the interface.
2
Name:
Anonymous
2010-09-18 23:00
no Exceptions
3
Name:
Anonymous
2010-09-18 23:06
Are you saying setIsCool() and getIsCool() should be used?
4
Name:
Anonymous
2010-09-18 23:21
Even if the question is simple, is it cool to post cryptic two-word answers in a sage?
5
Name:
Anonymous
2010-09-19 0:26
Stop using getters and setters.
6
Name:
Anonymous
2010-09-19 0:28
is_cool = property(_get_is_cool, _set_is_cool)
Idiot.
7
Name:
Anonymous
2010-09-19 0:46
Figured this one out: since I'm using C# I can just define properties that set and get member variables. Clean and smart.
as in:
private bool isCool;
public bool IsCool
{
get
{
return isCool;
}
set
{
isCool = value;
}
}
Then you can just go MyClass.isCool = true;
or if (MyClass.isCool)
Definitely a nice thing to include in that language for a number of other reasons too.
8
Name:
Anonymous
2010-09-19 1:29
>>7
You wouldn't know ``clean and smart'' if it punched you in the anus.
9
Name:
Anonymous
2010-09-19 2:42
trolled constantly
10
Name:
Anonymous
2010-09-19 2:59
>>9
But is it the same person trolling?
11
Name:
Anonymous
2010-09-19 4:00
I liked this troll.
Novice, but effective.
C#, oh my.
12
Name:
Anonymous
2010-09-19 5:10
14
Name:
Anonymous
2010-12-06 9:02
B a c k t o / b / , ` ` G N A A F a g g o t ' '
15
Name:
Anonymous
2010-12-06 9:14
B a c k t o / b / , ` ` G N A A F a g g o t ' '