Unexpected cast when declaring a field without type


#1

Hello.

Today I found something strange when tried to declare one of my fields.
That’s this declaration:

private val users = ConcurrentHashMap<Int, User>()

What type of users would you expect to see here?

The answer

Okay, the type of users is Iterable<User>
Maybe I misunderstood something, but it looks really strange for me. Why does it work in that way?

I’m sorry. There was a function argument with the same name.
Really sorry for this.


#2

I can’t reproduce this on try.kotlinlang.org. How are you getting the type of the field?