26) ElixirConf US 2018 Lightning Talk – Kernel functions you'll want to start using – Moxley Stratton

elixirconf2018

#1

ElixirConf US 2018 Lightning Talk – Kernel functions you’ll want to start using – Moxley Stratton (@moxley)

All talks are available in the ElixirConf US 2018 Talks List or via the #elixirconf2018 tag


#2

Nice talk!

I wonder how many people opt to use shortcuts like those mentioned?

Such as:

List.first(items)

vs

hd(items)

and:

Enum.count(items)

vs

length(items)

#3

Depends on the types. List.first([]) will return nil but hd([]) will throw an error, and Enum.count(...) works on any enumerable and length/1 only works on lists (byte_size or bit_size for binaries and map_size for maps). Plus hd/length work in guards where the others do not.

But I use the type-specific forms when at all possible to help ensure proper types. :slight_smile: