# Temporary variables

**URL:** <https://forum.kirupa.com/t/temporary-variables/325929>\
**Category:** Uncategorized\
**Created:** [November 12, 2011, 2:51am UTC](https://forum.kirupa.com/t/temporary-variables/325929 "2011-11-12T02:51:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drpelz](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@drpelz](https://forum.kirupa.com/u/drpelz)\
**Post date:** [November 12, 2011, 2:51am UTC](https://forum.kirupa.com/t/temporary-variables/325929/1 "2011-11-12T02:51:21Z")

</div>

hi folks,

I would like to know what’s the difference when I write a temporary variable like this (these are just examples):

version1

```auto

for each tempEnemy in enemyManager.enemies {
	var tempX:int = tempEnemy.x;
}

```

or this:

version2

```auto

for each tempEnemy in enemyManager.enemies {
	tempEnemy.oldX = tempEnemy.x;
}

```

What’s wrong and right? Currently I write it like version 2 and I’m not sure if I should change it to version 1. Can someone help me out with this please? I know most developers write like version 1 but I’m a little bit confused because I am totally unaware about version 1. If I use version 1 does that mean that my value is stored explicitly in a temporary variable that is cleared in every cycle?
