Method overloading in AL
Yet another cool feature in AL is method overloading. Imagine having a method being able to accept different paramters. What’s very common in most other modern languages just arrived in BC right now. In good old C/AL times you would have created several different methods… probably with some kind of a proxy method to prevent code duplication.
Today, luckily, we have the possibility to use method overloading. So, we’re able to define one an the same method, but with different parameters and implementations.
Probably the most important advantage of method overloading in AL is extensibility. We can extend already existing methods e.g. in the BaseApp or other extensions!
Example
local procedure MyProcedure(TextVar: Text)
begin
//Implementation A
end;
//Same method name, but different paramters
local procedure MyProcedure(TextVar: Text; DecimalVar: Decimal)
begin
//Implementation B
end;
And now the cool thing… VS Code shows the overloads: