On 2018-01-12 19:09, 'Axel Wagner' via golang-nuts wrote:
>     One would think the result is rather well defined.
> 
> 
> It's not. The value in the interface doesn't have to be a pointer, so
> this is, in general, not defined at all.

No, but it's not like you cannot ask about interface{} in general.
I can do a type switch, asking:

func f(i interface{}) int {
  switch t := i.(type) {
  case int:
    return t
  default:
     return 0
  }
}


Now I just wondered how to do something like a parameterized version of
that:

func f(i interface{}) o interface{} {
  switch t := i.(type) {
  case **<Something>:
     o = *t
  default:
     o = nil
  }
  return
}


When you say "well defined" you refer to that an interface{} can be
anything until you do reflection or type assertion.

When I say "well defined", I speak of whether it's in general is
ambiguous what is meant.

/Peter

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to