Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I reference a specific function overload?

Tags:

kotlin

kdoc

Given the following code

fun example() {}

fun example(name: String) {}

How can I reference a specific function? I.e. example() or example(String)?

Using [example] I can't specify which exactly function I want.

like image 475
Mibac Avatar asked May 08 '17 19:05

Mibac


People also ask

What are the restrictions on overloaded functions?

Restrictions on overloadingAny two functions in a set of overloaded functions must have different argument lists. Overloading functions that have argument lists of the same types, based on return type alone, is an error.

Why return value is not considered as function overloading criteria?

The return type of a function has no effect on function overloading, therefore the same function signature with different return type will not be overloaded. Example: if there are two functions: int sum() and float sum(), these two will generate a compile-time error as function overloading is not possible here.

How are overloaded functions differentiated?

Overloaded functions differentiate between argument types that take different initializers. Therefore, an argument of a given type and a reference to that type are considered the same for the purposes of overloading. They're considered the same because they take the same initializers.

Which of the following is an example of function overloading?

Example 2: Overloading Using Different Number of Parameters Note: In C++, many standard library functions are overloaded. For example, the sqrt() function can take double , float , int, etc. as parameters. This is possible because the sqrt() function is overloaded in C++.


1 Answers

At this time you can't. Dokka generates all overloads of a function on a single page, and the link points to that page, so you can simply specify the overload you need as text: "the one-argument overload of [example]".

There is an open issue for adding the possibility to link to a specific overload, but we aren't too happy with the proposed syntax, so we don't have a definite plan to support this.

like image 91
yole Avatar answered Sep 22 '22 05:09

yole