# Set function that will work for ALL variables

**URL:** <https://forum.kirupa.com/t/set-function-that-will-work-for-all-variables/321966>\
**Category:** Uncategorized\
**Created:** [May 5, 2011, 6:31pm UTC](https://forum.kirupa.com/t/set-function-that-will-work-for-all-variables/321966 "2011-05-05T18:31:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cakepizza](https://avatars.discourse-cdn.com/v4/letter/c/45deac/32.png) [@cakepizza](https://forum.kirupa.com/u/cakepizza)\
**Post date:** [May 5, 2011, 6:31pm UTC](https://forum.kirupa.com/t/set-function-that-will-work-for-all-variables/321966/1 "2011-05-05T18:31:33Z")

</div>

By chance does anyone know if there is a way to make a set function for my class that will run regardless of what variable is being set?  
like if someone does…  
anInstanceOfMyClass.anyVariable=“whatever”;  
it will always run function X.

I want my code to have a function that runs every time someone tries to set the value of a variable in my class, or create a new variable that does not even exist yet in the class.
