Recent Posts

Using Ruby’s each_with_object

1 minute read

Sometimes we’d like to build a new collection object from the elements of another collection. One trivial example would be element occurrence counting, whic...

Regexp anchors in Ruby

1 minute read

Some Rubyists, when faced with the task of matching against the beginning or the end of a string, are prone to using ^ and $ in their regular expressions. Mo...

Using Ruby’s gsub with a hash

less than 1 minute read

Recently we discussed how you can use String#gsub with a block. Today we’ll examine another somewhat unknown feature of the gsub method - the ability to supp...