- Chapter 1 and 2 — OOP, Functional Programming, and Pattern Matching
- Chapter 3 — Immutability
- Chapter 4 — Basic Elixir Types
- Chapter 5 — Anonymous Functions (this post)
- Chapter 6 — Modules and Named Functions (coming soon)
- Chapter 7 — Lists and Recursion (coming soon)
- Chapter 8 and 9 — Maps, Structs, and Keyword Lists in Detail (coming soon)
- Chapter 10 — Processing Collections (coming soon)
- Chapter 11 — Strings and Binaries (coming soon)
- Chapter 12 — Control Flow (coming soon)
Welcome back to my 4th post in this series where I share key learnings from each chapter of Programming Elixir 1.6. If you haven’t read my previous posts yet, feel free to check those out first before continuing. In this post, I’ll be discussing anonymous functions in Elixir.
Chapter 5
- Basic syntax of anonymous functions
Anonymous functions begin with the fn
keyword and end with the end
keyword. In between the fn
and end
keywords, you declare your parameter list followed by your function body. So far, this is very similar to other languages like JavaScript and Ruby.