Thread: Gs3
View Single Post
  #90  
Old 06-16-2013, 04:58 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
My desires:

Constructors (being able to overload would also be awesome but perhaps taking it too far)
PHP Code:
class Test {
  var 
myname : string;
  var 
myage : int;

  function 
Test(myname: string) {
    
this.myname = myname;
  }
  
//Because overloading is fun
  
function Test(myname : string, myage : number) {
    
this.myname = myname;
    
this.myage = myage;
  }

  function 
echoValues() : void {
    
printf("My name is %s and my age is %i", this.myname, (this.myage? this.myage : "Unknown"));
  }
}

function 
onCreated() : void {
  var 
TestObj : Test = new Test("Twinny", 25);
  
TestObj.echoValues(); 
I know getters/setters will be on the way but this just seems more natural.

I added that printf as it will fail since it's not being referenced in that class(see: extern). For this, perhaps being able to simply prepend global. to global functions would be better. On a similar note, i've not tried but i hope we could use something like super.whatever to access base class items we inherited from :o
Reply With Quote