Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Understanding Nil

Gopher Academy via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Explore the intricacies of 'nil' in Go programming through this GopherCon 2016 talk by Francesc Campoy. Delve into the concept of nil as a zero value, its historical context, and its significance across various data types. Discover when nil is not actually nil, learn best practices for error handling, and understand the practical applications of nil in receivers, slices, and maps. Gain insights into leveraging nil channels in select statements, using nil interfaces for default signaling, and recognizing the overall utility of nil in Go programming. Through code examples and explanations, master the nuances of nil to write more efficient and idiomatic Go code.

Syllabus

Intro
welcome every single one of you
nil is (a) zero
interlude a bit of history
zero values what are they?
the type of nil
nil is a predeclared identifier representing the zero value for a pointer, channel, func, interface, map, or slice type.
zero values what do they mean?
type, value
when is nil not nil?
do not declare concrete error vars
do not return concrete error types
nil receivers are useful
use nil slices they're often fast enough
use nil maps as read-only empty maps
coding time
can we switch off a chan?
use nil chans to disable a select case
'nil values can satisfy interfaces
use nil interfaces to signal default
nil is useful

Taught by

Gopher Academy

Reviews

Start your review of Understanding Nil

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.