Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 204 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to fix Overload Resolution Ambiguity in Kotlin (no lambda)?

#1
I am having Overload Resolution Ambiguity error in this line:

`departureHourChoice!!.selectionModel.select(currentHourIndex)`

For Reference:

- `departureHourChoice` is a `ChoiceBox<Int>`, which is from `java.scene.control`

- `currentHourIndex` is an `Int`

- The Overload Resolution Ambiguity happens in the `.select()` method; It is overloaded and can accept two kinds of parameters: `(T obj)` or `(int index)`.

- The `.select()` method allows for an item in a `ChoiceBox` to be selected, and you can determine which one can be selected by referencing to that item or to it's index. In this case, I want it to be selected by Index (`int`).

- Here is a photo of the error[![enter image description here][1]][1]

How would one resolve the Overload Resolution Ambiguity?


[1]:
Reply

#2
Try casting to `Int`:

departureHourChoice!!.selectionModel.select(currentHourIndex as Int)
Reply

#3
It seems that you are hit by [this bug](

[To see links please register here]

) as a workaround you can :

- box the `currentHourIndex`:

lateinit var departureHourChoice: ChoiceBox<Int>
...
val currentHourIndex = 1
departureHourChoice.selectionModel.select(currentHourIndex as Int?)

- or change declaration of `ChoiceBox` to use `java.lang.Integer` instead of Kotlin's `Int`:

lateinit var departureHourChoice: ChoiceBox<java.lang.Integer>
...
val currentHourIndex = 1
departureHourChoice.selectionModel.select(currentHourIndex)

Further reading:

-

[To see links please register here]

-

[To see links please register here]

Reply

#4
The solution for me in similar situation is to define in your import for example:
import kotlin.math.sqrt as kotsqrt

then use as:
val a = kotsqrt(2.3)
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through