Damn :slightly_smiling_face: ```> Map m = [:]...
# groovy
g
Damn 🙂
Copy code
> Map m = [:]
> m in Serializable

Result: true
v
Still interesting that it prefers
Serializable
over
Map
though
g
That is also true.. It would be interesting to know what Java would have done
v
image.png
g
I cannot try at the moment, does it have the same behaviour?
v
Just look at the screenshot
g
Got it
@paulk_asert is that the intended behaviour or it can be considered as a bug?
p
I'd have to look at the distance algorithm. I also wonder whether using
LinkedHashMap
would be a workaround for you? In any case, always feel free to create an issue and we can always close once we have confirmed behavior - that acts as extra information for future folks who stumble along the same path.
v
As it is different from Java behavior and Groovy targets to be "the Java scripting language", I'd tend to agree that the behavior is not correct. 🙂 If the method receives
LinkedHashMap
instead of
Map
it is indeed selected also by Groovy.
p
It is not as simple as doing exactly what Java does. Groovy supports multi-methods. It selects the best matching method based on actual runtime time.
g