Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

# Keyword Lists A `Keyword` list is a list of key-value pairs that has three special characteristics: 1. Keys must be `Atom`s. 1. The key-value pairs are ordered. 1. Keys can be duplicated. Here's how to use keyword lists: ```elixir keyword = [name: "Peter", age: 32, name: "Pietah"] # Access an element using the bracket notation keyword[:age] # => 32 # But it will only return the first key keyword[:name] # => "Peter" # You can also use a helper function Keyword.get(keyword, :age) # => 32 # Replace an existing value with a new one Keyword.replace(keyword, :age, 33) # => [name: "Peter", age: 33, name: "Pietah"] # But when you update a duplicate key, it will only keep the new value and remove the rest Keyword.replace(keyword, :name, "Pieter") # => [name: "Pieter", age: 32] # Delete all pairs that have a given key Keyword.delete(keyword, :name) # => [age: 32] # Only delete the first occurrence Keyword.delete_first(keyword, :name) # => [age: 32, name: "Pietah"] ```
See source

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run on your machine

with Livebook Desktop

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More ×