It boils down to the meaning of interface{}.
interface{} means interface{} and _not_ "any type".
While you can assign anything to a variable of type interface{}
this does not mean that a variable of type interface{} _is_
"any type". There is no "any type" type in Go.
V.
On Sunday, 23 February 202
This is a great write-up! Going from explaining the terms to applying the
terms to the actual problems.
I learned a lot. Thanks.
On Sunday, February 23, 2020 at 5:37:56 PM UTC+8, Axel Wagner wrote:
>
> Hi,
>
> I've wrote about the theoretical side of that here:
> https://blog.merovius.de/2018/06
Go is a statically typed language, but the time you get into the case,
you must know the concrete type of the v. You allows it to be either
map[string]interface{} or map[string]int, this is not a single known
type, so the original input type (interface{}) is used.
On Sun, 2020-02-23 at 01:24 -0800
Hi,
I've wrote about the theoretical side of that here:
https://blog.merovius.de/2018/06/03/why-doesnt-go-have-variance-in.html
The post uses slices, but the same arguments apply to maps as well.
Specifically, while it *may* seem like you should be able to use a
map[string]int as a map[string]inte
Another slightly related topic:
switch v := i.(type) {
case map[string]interface{}, map[string]int:
fmt.Print(v)
}
Ideally v is of type map[string]interface{}, but it's interface{} instead.
On Sunday, February 23, 2020 at 5:12:27 PM UTC+8, Glen Huang wrote:
>
> Hi,
>
> I have a function tha