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 interfaces. 
> That is, the value must have an m() method as well as all of io.reader 
> methods or the type assertion will like the above assertion to a string 
> type.
>

It would be great if the spec can explain things as clear as you.
 

>
> On Oct 13, 2016 7:48 AM, <di...@veryhaha.com <javascript:>> wrote:
>
>
>
> On Thursday, October 13, 2016 at 8:52:14 PM UTC+8, Jan Mercl wrote:
>
>> On Thu, Oct 13, 2016 at 2:42 PM <di...@veryhaha.com> 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 that's how it was declared 
>> and nothing not implementing I can be assigned to it. The dynamic type of y 
>> can implement any number of interfaces, so it can implement both I and 
>> io.Reader. The later is checked at run time when the type assertion 
>> expression y.(io.Reader) is actually evaluated.
>>
>> -- 
>>
>> -j
>>
>
> So "y must implement both I and io.Reader" means short form of "the 
> dynamic type of y must implement both I and io.Reader"?
> My brain really can't accept this short form.
>
> And in that example, it gives people the impression y is nil. I really 
> think it is a bad example.
>
>
>
>
>
>
> I feel that comment (and that example) is very not professional for these 
> reason:
> 1. y is a value of type I, 
>
>
> -- 
> 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...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

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