Skip to content

Commit 74584ad

Browse files
author
José Valim
committed
s/records/structs in protocols docs
1 parent 47f57d6 commit 74584ad

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,8 +3364,10 @@ defmodule Kernel do
33643364
end
33653365

33663366
@doc """
3367-
Defines a module as a protocol and specifies the API that
3368-
should be defined by its implementations.
3367+
Defines a protocol.
3368+
3369+
A protocol specifies an API that should be defined by its
3370+
implementations.
33693371
33703372
## Examples
33713373
@@ -3407,7 +3409,7 @@ defmodule Kernel do
34073409
And we would have to define the implementation for all types.
34083410
The supported types available are:
34093411
3410-
* Record (see below)
3412+
* Structs (see below)
34113413
* Tuple
34123414
* Atom
34133415
* List
@@ -3416,23 +3418,24 @@ defmodule Kernel do
34163418
* Float
34173419
* Function
34183420
* PID
3421+
* Map
34193422
* Port
34203423
* Reference
34213424
* Any (see below)
34223425
3423-
## Protocols + Records
3426+
## Protocols + Structs
34243427
3425-
The real benefit of protocols comes when mixed with records.
3428+
The real benefit of protocols comes when mixed with structs.
34263429
For instance, Elixir ships with many data types implemented as
3427-
records, like `HashDict` and `HashSet`. We can implement the
3430+
structs, like `HashDict` and `HashSet`. We can implement the
34283431
`Blank` protocol for those types as well:
34293432
3430-
defimpl Blank, for: HashDict do
3433+
defimpl Blank, for: [HashDict, HashSet] do
34313434
def blank?(dict), do: Dict.empty?(dict)
34323435
end
34333436
3434-
Since records are tuples, if a protocol is not found a given
3435-
type, it will fallback to `Tuple`.
3437+
If a protocol is not found for a given type, it will fallback to
3438+
`Any`.
34363439
34373440
## Fallback to any
34383441
@@ -3466,8 +3469,8 @@ defmodule Kernel do
34663469
34673470
## Types
34683471
3469-
As in records, defining a protocol automatically defines a type
3470-
named `t`, which can be used as:
3472+
Defining a protocol automatically defines a type named `t`, which
3473+
can be used as:
34713474
34723475
@spec present?(Blank.t) :: boolean
34733476
def present?(blank) do

0 commit comments

Comments
 (0)