Sign in to follow this  
Followers 0
Nezoic

Function Overloading

3 posts in this topic

I couldn't find any information on overloading function with different parameter signatures so I figured I would ask if it was possible. 

For example

Func AddStuff($a)
    ;overloads AddStuff($a, $b, $c) Same function name but different param signature overloads
    Return MyFunc($a, 0, 0)
End Func

Func AddStuff($a, $b)
    ;overloads AddStuff($a, $b, $c) Same function name but different param signature overloads
    Return MyFunc($a, $b, 0)
End Func

Func AddStuff($a, $b, $c)
    ;Work is done in primary function
    Return $d = $a + $b + $c
End Func

Share this post


Link to post
Share on other sites



In AutoIt you make use of default parameters:

Func AddStuff($a, $b = 0, $c = 0)
    Return $a + $b + $c
EndFunc

That function can take one, two or three arguments now.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0