Be a Supporter!

Quick question about "this"

  • 234 Views
  • 2 Replies
New Topic Respond to this Topic
Jigganis
Jigganis
  • Member since: Nov. 7, 2003
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Quick question about "this" 2008-10-10 15:09:07 Reply

Okay. I have this code here from a book I'm reading, and I don't quite understand what those "this" refers to in the constructor method body. Hoping some kind soul could clear it up for me here T_T

package zoo {
public class VirtualZoo {
private var pet;

public function VirtualZoo ( ) {
this.pet = new VirtualPet("Stan");
this.pet.getAge( );
}
}
}

K-Guare
K-Guare
  • Member since: May. 23, 2008
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Quick question about "this" 2008-10-10 15:17:07 Reply

'this' refers to the object your putting the code on.
Check out AS: Hierarchy for more info. :]


what

BBS Signature
Jigganis
Jigganis
  • Member since: Nov. 7, 2003
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Quick question about "this" 2008-10-10 15:20:39 Reply

Thought it had something to do with that... Thanks man! Especially thankful for that list. I'm going to go read it now. :D