@lan @Shulhan
Thanks. Glad to know the design goal much better.
On Tuesday, April 14, 2020 at 1:07:36 PM UTC+8, Ian Lance Taylor wrote:
>
> On Mon, Apr 13, 2020 at 6:56 PM Glen Huang >
> wrote:
> >
> > Given
> >
> > type Data []byte
> > s := [][]byte{{1},{2}}
> >
> > I wonder why this
On Mon, Apr 13, 2020 at 6:56 PM Glen Huang wrote:
>
> Given
>
> type Data []byte
> s := [][]byte{{1},{2}}
>
> I wonder why this conversion isn't allowed?
>
> []Data(s)
>
> Seems pretty straightforward. Maybe I miss some edge cases where things won't
> square?
> On 14 Apr 2020, at 09.46, Glen Huang wrote:
>
> With all due respect, I think assigning to interface{} is orthogonal to the
> question, which deals with variance. (I asked about it here:
> https://groups.google.com/forum/#!topic/golang-nuts/S4p54OpQHGw)
>
> Here, the type is redefined, so
With all due respect, I think assigning to interface{} is orthogonal to the
question, which deals with variance. (I asked about it
here: https://groups.google.com/forum/#!topic/golang-nuts/S4p54OpQHGw)
Here, the type is redefined, so in the context of conversion, it and the
original should be
Go doesn't do any implicit type conversions, and it's quite consistent
about that. The only things which are type "converted" are untyped
constants.
I would love for this to work too, by the way, since I often come up with
something like:
var a []interface{}
var b []SomethingConcrete
I would
Given
type Data []byte
s := [][]byte{{1},{2}}
I wonder why this conversion isn't allowed?
[]Data(s)
Seems pretty straightforward. Maybe I miss some edge cases where things
won't square?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To