How to create this Overloaded method

I have no idea how to describe this method. My confusion is on several points.
(Note: the actual method’s code is my variation, but substantially the same.)

Part 1. The method is in 2 parts. How did it get created?

a. It looks in the IDE as
Data (with a disclosure triangle)
(First half) () as String // this is the 2nd half but it shows first alphabetically
(2nd half) (Assigns data as String)
An Image for clarity
Sorry image doesn’t work for me. Here’s a linkData Method

Part 2. How does it know which piece to call?
a. In the App.Open event, the line is:
me.RecentItems.Data = ts.ReadAll // which calls the Assigns half.

 b.  In the App.Close event, the line is:
        [code]  Ir.Write DefineEncoding(me.RecentItems.Data, Encdng)[/code] //which calls the other half

The code is below in case that will help.
It is from [quote]Designing a Recent Items Submenu, By Charles Yeomans[/quote]
The code for the Data method looks like:

[code]Public Sub Data(Assigns data as String)
dim arr(), riLst() as String
dim i, j as Integer
dim f as FolderItem

riLst = Split(data, EOL)
For i = 0 To UBound(riLst)
arr = split(data, DSep)
For j = 0 to UBound(arr)
f = GetFolderItem(arr(i), 3)
if f.Exists then
me.Add f
// file is gone
Catch e as NilObjectException
// path is gone
End Try
Next//For j = 0 to UBound(arr)
Next//For i = 0 To UBound(riLst)

End Sub

Public Function Data() as String
dim output as String
dim i as Integer

For i = UBound(me.RecentItemsQueue) DownTo 0
output = output + me.RecentItemsQueue(i).File.NativePath + DSep + me.RecentItemsQueue(i).Text + DSep + me.RecentItemsQueue(i).Tag + EOL
return Trim(output)

End Function

The overloading section of this page should help:$overloading

Overloads can be tricky, but powerful.
The main requirement is that the signature of each overload be DIFFERENT (in terms of datatypes more so than variable names)

Thanks. It’s overloading.

How do I get there? It doesn’t show under insert. I saw the part of giving the same name. Is it that simple

How does it know which one to go to? I assume it’s Assigns versus () but that only partly makes sense.

I looked up overloading and there’s no description about this part of overloading.

There is no insert… you just create it as if two methods… give it the same name , but a DIFFERENT signature

SUB myMethod(a as integer,b as string) // "a as integer,b as string" is the signature

It goes to the one where the calling code matches the supplied signature, which is why they MUST be different

Sub myMethod as String
return zString
end sub
Sub myMethod(assigns newvalue as string)
end sub

This is an overload that mimics a Computed Property… normally you would NOT use this particular syntax, as a computed property is better… but I think it illustrates the process… The big advantage is you can pass arguments to Overloaded methods, but cannot pass them to computed properties.

I’m going to read those articles on Assigns one of these days

Computed properties arent better or worse they’re different. But, a method pair like this can be overridden in a subclass, a computed property can’t be. That is a significant difference.

by “better” I meant cleaner syntax in most cases…
but the significant difference is the ability to pass parameters to an overload, allowing you to create a setter/getter scenario for an array for example

Both types exist to allow the developer the flexibilty to choose the way that works best. I have code with hundreds of overloads (ok, dozens), and also has dozens of computed properties

The consumer of a class that uses overloaded methods vs computed properties uses the exact same syntax. The provider can switch between these invisibly to the users of such a class. The code that uses the class cannot tell which it is.

While being able to pass parameters to the method pair is one difference that is often useful, the biggest difference is that subclasses can override the method pair and cannot override the computed property (even with a redeclared property it’s a shadow and shadowing will cause issues at times).