On Friday, October 14, 2016 at 1:33:52 AM UTC+8, di...@veryhaha.com wrote:
>
>
>
> On Friday, October 14, 2016 at 1:28:01 AM UTC+8, di...@veryhaha.com wrote:
>>
>>
>>
>> On Thursday, October 13, 2016 at 11:22:14 PM UTC+8, Chris Manghane wrote:
>>>
>>> In that example y is a nil interface value
On Friday, October 14, 2016 at 1:28:01 AM UTC+8, di...@veryhaha.com wrote:
>
>
>
> On Thursday, October 13, 2016 at 11:22:14 PM UTC+8, Chris Manghane wrote:
>>
>> In that example y is a nil interface value of type l. The last line
>> implies that for a type assertion to another interface type,
On Thursday, October 13, 2016 at 11:22:14 PM UTC+8, Chris Manghane wrote:
>
> In that example y is a nil interface value of type l. The last line
> implies that for a type assertion to another interface type, the operation
> will only be possible if the underlying value implements both
On Thursday, October 13, 2016 at 11:22:14 PM UTC+8, Chris Manghane wrote:
>
> In that example y is a nil interface value of type l. The last line
> implies that for a type assertion to another interface type, the operation
> will only be possible if the underlying value implements both
In that example y is a nil interface value of type l. The last line implies
that for a type assertion to another interface type, the operation will
only be possible if the underlying value implements both interfaces. That
is, the value must have an m() method as well as all of io.reader methods
or
On Thursday, October 13, 2016 at 8:52:14 PM UTC+8, Jan Mercl wrote:
>
> On Thu, Oct 13, 2016 at 2:42 PM wrote:
>
> > I don't understand the comment of the last line. Can someone explain it
> for me?
>
> "r has type io.Reader" means that the type if expr.(T) is T.
>
> "and
On Thu, Oct 13, 2016 at 2:42 PM wrote:
> I don't understand the comment of the last line. Can someone explain it
for me?
"r has type io.Reader" means that the type if expr.(T) is T.
"and y must implement both I and io.Reader"
y is either nil or it implements I, because
https://golang.org/ref/spec#Type_assertions
var x interface{} = 7 // x has dynamic type int and value 7
i := x.(int) // i has type int and value 7
type I interface { m() }
var y I
s := y.(string)// illegal: string does not implement I (missing
method m)