# Function Overhead

**URL:** <https://forum.kirupa.com/t/function-overhead/174128>\
**Category:** flash\
**Created:** [January 3, 2006, 4:48am UTC](https://forum.kirupa.com/t/function-overhead/174128 "2006-01-03T04:48:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sinister\_Shadow](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@Sinister\_Shadow](https://forum.kirupa.com/u/Sinister_Shadow)\
**Post date:** [January 3, 2006, 4:48am UTC](https://forum.kirupa.com/t/function-overhead/174128/1 "2006-01-03T04:48:34Z")

</div>

Now I’m just being curious but I wanted to know how much of a difference there is between accessing a variable directly and accessing it through get/set functions.

e.g.

```auto
class someClass
{
 public var hello:String = "Hello";
 private var bye:String = "Bye";
 
 public function someClass(){}
 
 public function getBye():String
 {
  return bye;
 }
 
 public function setBye(newVal:String):Boolean
 {
  if (newVal != hello)
  {
   bye = newVal;
   return true;
  }
  else
   return false;
 }
}

```

```auto
var someVar:someClass = new someClass;
 
trace someVar.hello; //outputs "Hello"
someVar.hello = "Konnichiwa";
trace someVar.hello //outputs "Konnichiwa"
 
trace someVar.getBye(); //outputs "Bye"
someVar.setBye("Ja ne");
trace someVar.getBye(); //outputs "Ja ne"

```

What’s the difference (apart from allowing error checking as shown in someClass.setBye())?

[ot]Edit: [noparse][as2][/as2] doesn’t work![/noparse][/ot]
