Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

variable and function with same name

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.

Name: Anonymous 2010-09-18 23:00

no Exceptions

Name: Anonymous 2010-09-18 23:06

Are you saying setIsCool() and getIsCool() should be used?

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?

Name: Anonymous 2010-09-19 0:26

Stop using getters and setters.

Name: Anonymous 2010-09-19 0:28

is_cool = property(_get_is_cool, _set_is_cool)

Idiot.

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.

Name: Anonymous 2010-09-19 1:29

>>7
You wouldn't know ``clean and smart'' if it punched you in the anus.

Name: Anonymous 2010-09-19 2:42

trolled constantly

Name: Anonymous 2010-09-19 2:59

>>9
But is it the same person trolling?

Name: Anonymous 2010-09-19 4:00

I liked this troll.
Novice, but effective.
C#, oh my.

Name: Anonymous 2010-09-19 5:10

>>5
/thread

Name: Anonymous 2010-12-06 9:02

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2010-12-06 9:14

Back to /b/, ``GNAA Faggot''

Don't change these.
Name: Email:
Entire Thread Thread List