Sub-methods?

Just found this by accident:

Can’t find anything in the documentation about this. What exactly do we use sub-methods for?

Nevermind.
I knew it had something to do with overloading, and I finally found it in the user guide.

what is it for ?

Overloading :wink:

AFAIK, there is no such thing as “sub methods”. If you have two methods with identical name and taking or returning different parameters, they will appear that way.

The above picture is just… deceiving :wink:

these are methods inside a method, it is not overloading ?

It is, but the above picture tends to deceive you on thinking about methods into methods, that is something like lambdas :wink:

I would prefer classes into class…

For overloading the compiler looks at the parameters, but not at the return value.

Although it does take into account the presence of a return value.

Eli, I am sorry, but I just created two myMethod with s as string as parameter, one returning nothing, the second returning string, and this executes perfectly :

MyMethod("testing") msgbox MyMethod("testing")

So what you allege is not entirely true. The compiler perfectly knows how use the return to differentiate between a sub and a function of the same name.

Of course, if a third method was to return an integer instead of a string, then the compiler gets confused.

I will admit that I was having a bit of fun when I filled in the parameter fields.

How this came about was that I wanted to make changes to a method, and decided to make a duplicate, in case I had to go back to the original. So, I duplicated the original method, and went to rename the original and the dup. But I wasn’t paying attention where I was typing, and ended up with both having the same name. When I looked up at the screen, I saw the two methods nested under the same name, and had no idea how it happened. Eventually figured out that this is how overloaded methods are displayed, so the mystery was solved.