VBScript Question: Parens

KingKaeru

Supreme [H]ardness
Joined
Jul 16, 2000
Messages
6,465
Any VBScript folk in the house know the difference between the following notations?

Code:
Dim objCar 
Dim objWorld 

Set objCar = Server.CreateObject("Car");
Set objWorld = Server.CreateObject("World");

'no parens
strResult = objWorld.consume(objCar)
'with parens
strResult = objWorld.consume((objCar))
 
The extra () makes a copy of the value or object.

For example, if you had a sub or function that takes a byref argument and modifies the value, objWorld.consume(objCar) would/could modify objCar. Calling the same function with objWorld.consume((objCar)) would discard any changes to objCar since the original object reference isn't passed.
 
Back
Top