Class methods don't raise an error when parameter missing

Get help with using AutoHotkey and its commands and hotkeys
logithack1337
Posts: 11
Joined: 18 Dec 2015, 02:58

Class methods don't raise an error when parameter missing

25 Sep 2017, 06:15

Hey everyone,

I'm not sure if this is actually a bug, but I've just encountered some strange behaviour when calling a class method without passing a parameter to it. I've discussed this with sj1k (Sjc1000) and a few other guys on #ahk and they hadn't experienced that problem before either.

Consider this code (expand):

Code: Select all

class Test {
	method(val) {
		MsgBox val: %val%
	}
}

function()  ; raises error

t := new Test()
t.method()  ; just stops
ExitApp


function(val) {
	MsgBox val: %val%
}
If function() is called without a parameter, it raises an error, whereas t.method() just stops. Has anyone encountered this before?

Thanks for your help!

Regards,

logithack
User avatar
nnnik
Posts: 3526
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Class methods don't raise an error when parameter missing

25 Sep 2017, 09:27

Yes I think it is intended.
Recommends AHK Studio
Helgef
Posts: 3298
Joined: 17 Jul 2016, 01:02
Contact:

Re: Class methods don't raise an error when parameter missing

25 Sep 2017, 10:38

I'm not sure where or if this is documented, but it is known and applies to all function references and bound funcs. :wave:
Cheers
Spoiler

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], eqv, gecko, Google [Bot], hidefguy, Mipha, Newbieyikes, pilgrim333, Xtra and 101 guests