After a few weeks of work, I’ve just released version 1.0 of my new gem: persistent-💎!
The objective of this gem is to make programming with immutable data structures in Ruby as joyful and frictionless as using the built-in
Hash classes. So easy, in fact, that using immutable structures becomes the norm, rather than the exception.
Ruby has no immutable data structures in the standard library, but it is flexible enough that we can add such functionality as a library, and disguise it so it almost looks like the built-in data structures.
For instance, with persistent-💎 you can create:
my_array = a💎[1, 2, 3]
my_hash = h💎[key1: 'foo', key2: 'bar']
my_set = s💎[:sephiroth, :kills, :aeris]
Using an emoji as part of the gem’s api was an interesting challenge, but with some care it’s possible to support Ruby 1.9.3 to 2.5.0, and JRuby 1.7 and 9.x, although the latter have some known bugs with unicode handling.
This was a very fun project, and the git history reveals that it took a bit more than I expected to get it just right.
So… go forth and use it. Feedback is very welcome!