Forum Topic: Why won't this function work..?

(48 views • 2 replies)

This topic is 1 page long.

<< < > >>
Resigned

Night-Mare

Reply To Post Reply & Quote

Posted at: 10/5/09 06:03 AM

Night-Mare FAB LEVEL 19

Sign-Up: 02/17/05

Posts: 4,577

var m1:Number = 0;
var m2:Number = 1;
function mCheck(a, b) {
	b = a;
}
mCheck(m1, m2);
t = m1+'-'+m2;
trace( t);

This function SHOULD trace 0-0.
But it doesn't even change the variable of m2 to m1.

Does anybody know the reasoning behind this?

// LochieLand.com // Wacom for me? :O // The-SFC. // My DA & CN. //
Click my sig. D':<

BBS Signature

None

Montycarlo

Reply To Post Reply & Quote

Posted at: 10/5/09 06:06 AM

Montycarlo LIGHT LEVEL 19

Sign-Up: 03/14/05

Posts: 742

You're passing the value of the variables as arguments, not the memory addresses of the variables.

Although practicality beats purity.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.


Blushing

Night-Mare

Reply To Post Reply & Quote

Posted at: 10/5/09 06:09 AM

Night-Mare FAB LEVEL 19

Sign-Up: 02/17/05

Posts: 4,577

Oh, I forgot they didn't actually pass the variable along with it.

My mistake, thanks mate. :)

// LochieLand.com // Wacom for me? :O // The-SFC. // My DA & CN. //
Click my sig. D':<

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 01:48 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!