In Ruby, all functions are methods, so the terms “function” and “method” are interchangeable in this article. In this article, I want to demonstrate a nice way to write functional-style code in Ruby. It is a way to write non-trivial pure functions, without a bunch of weird non-idiomatic code. I’ll start by defining what pure functions are, explaining their benefits, and then walk through an exampl