I use my own "automatic" type assertion library:

https://github.com/jaracil/ei

El jueves, 9 de junio de 2016, 22:39:46 (UTC+2), Pablo Rozas-Larraondo 
escribió:
>
> Sorry I should have been more clear exposing the problem. What I meant by 
> "automatic type assertion" was something like:
>
> If a is a variable of type interface{}:
> b := a.(a.(type)) as a way of getting a's value in its own type.
>
> As I'm writing this, I'm realising of the problem behind this though. The 
> type of b would be unkown and reflection ,or a type switch, would be 
> required to get its type again. So, there's no benefit in such a function I 
> guess.
>
> Thank you for your responses, sorry for the confusion and please comment 
> if you see it in a different way.
>
> Pablo
>
> On 10 Jun 2016, at 12:36 AM, Jan Mercl <0xj...@gmail.com <javascript:>> 
> wrote:
>
>
> On Thu, Jun 9, 2016 at 4:13 PM Pablo Rozas Larraondo <
> p.rozas....@gmail.com <javascript:>> wrote:
>
> > Does anyone know the reason why Go doesn't offer an automatic type 
> assertion of an interface into its underlying type? I know this could be 
> achieved by using a type switch or safe type assertions (b, ok := a.(int)) 
> but I'm wondering why this operation was not simplified or included as a 
> function in the reflection package.
>
> Please elaborate a bit more on what do you mean by "automatic type 
> assertion" and please give some small example of how you would design the 
> language feature and/or the reflection package functionality. Thanks.
>
> -- 
>
> -j
>
>

-- 
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