A
Andrew Morton
Is it possible to have two function declarations which take the same
parameters but return different types depending on how the function is used?
function f(x) as string
' return a string
end function
function f(x) as string()
' return an array of strings
end function
' somewhere in a subroutine:
Dim S As String=f(1) ' calls the string version of f(x)
Dim A As String()=f(2) ' calls the array version of f(x)
Why? Because I'm extracting IPTC metadata from a file, and some metadata has
a single value (e.g. the caption) and some may have multiple values (e.g.
the keywords). I just think it would look neater to have one function name.
Andrew
parameters but return different types depending on how the function is used?
function f(x) as string
' return a string
end function
function f(x) as string()
' return an array of strings
end function
' somewhere in a subroutine:
Dim S As String=f(1) ' calls the string version of f(x)
Dim A As String()=f(2) ' calls the array version of f(x)
Why? Because I'm extracting IPTC metadata from a file, and some metadata has
a single value (e.g. the caption) and some may have multiple values (e.g.
the keywords). I just think it would look neater to have one function name.
Andrew