FPOO Chapter 4: Encapsulating methods in the constructor

Note: This article is part of a series working through the exercises in Brian Marick's "Functional Programming for the Object-Oriented Programmer", in Elixir instead of Clojure. The full notes and source code are on GitHub.

Today I slightly refine the nascent OO implementation in Elixir. Here’s the new point constructor, with methods contained within it:

And here’s send_to, which (slightly) eases sending messages to objects.

Exercise 1: x, y, and add

This exercise re-adds x, y, and add methods.

This is all quite horrible so far; presumably I’ll be cleaning it up as I progress further in the book.