ooh.. thanks.
On Wednesday, June 3, 2020 at 10:21:24 AM UTC+3, kortschak wrote:
>
> It's perfectly valid to call a method on a nil receiver, so long at the
> nil receiver is not dereferenced.
>
> https://play.golang.org/p/Z-zXlj0-eVy
>
>
> On Wed, 2020-06-03 at 00:03 -0700, apma...@gmail.com
It's perfectly valid to call a method on a nil receiver, so long at the
nil receiver is not dereferenced.
https://play.golang.org/p/Z-zXlj0-eVy
On Wed, 2020-06-03 at 00:03 -0700, apmat...@gmail.com wrote:
> Read function at net.go is like this:
>
> func (c *conn) Read(b []byte) (int, error) {
Methods are part of the type, not of the value. It is perfectly safe to
call methods on a nil value.
On 03.06.20 09:03, apmat...@gmail.com wrote:
Read function at net.go is like this:
func (c *conn) Read(b []byte) (int, error) {
if !c.ok() {
the ok checks that c is non nil:
func (c
Read function at net.go is like this:
func (c *conn) Read(b []byte) (int, error) {
if !c.ok() {
the ok checks that c is non nil:
func (c *conn) ok() bool { return c != nil && c.fd != nil }
how can c ever be nil ? if it would c.ok() call would crash.
--
You received this message because