Access base object methods with child properties.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

Access base object methods with child properties.

29 Apr 2015, 17:21

Hello,

In javascript there is a method called call. In that method you pass the "object" you want to operate on. This is really useful when you want to override a class method just partially, or you want to use it at some point of the child class.

For example:

Code: Select all

class parent {
   __New(bar){
      this.foo:=bar
  }
    hello(){
      return this.foo
    }
}

class child extends parent{

    hello(){
      msgbox, % base.hello()
    }
  
}
So when I do:

Code: Select all

test := new child("Hi")
test.hello()
I expect a msgbox that says "Hi"

In the documentation says that the this object is added as first parameter, so when i access base method it should get the child object in his this reference. What am I missing? What I did wrong?

Thanks in advance.

Docu
•base.Method() always invokes the base of the class where the current method was defined, even if this is derived from a sub-class of that class or some other class entirely.
•base.Method() implicitly passes this as the first (hidden) parameter.
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

Re: Access base object methods with child properties.

29 Apr 2015, 17:23

Dam it! this code works. I tested it and it works. Then I have to review what I have done bad in my real project.
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Access base object methods with child properties.

29 Apr 2015, 19:13

You have posted in the wrong forum (Scripts & Functions). I have moved the topic.

Also, please keep your misspelled swear word to yourself. ;)
Spoiler
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

Re: Access base object methods with child properties.

30 Apr 2015, 03:25

lexikos wrote:You have posted in the wrong forum (Scripts & Functions). I have moved the topic.

Also, please keep your misspelled swear word to yourself. ;)
Spoiler

Sorry for posting in the wrong forum. I think it was because I had it opened already. Thanks for moving.

I will take your suggestion about my misspelled word

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], bobstoner289, Google [Bot], peter_ahk, Spawnova and 352 guests