Meet this huge collection of Ruby one-liners! Mostly file oriented stuff, like adding blank lines into files, adding line numbers into text files, counting lines, selective printing of certain lines… But very useful. As a bonus, you’ll find the links to the other lists with different Ruby one-liners!
To start from, the concept of a one-liner program has been known since the 1960s with the release of the APL programming language. With its terse syntax and powerful mathematical operators, APL allowed useful programs to be represented in a few symbols.
Benoit Hamelin created this list himself, and it is worth sharing! He made a list of
- File spacing
- Numbering and calculations
- String creation
- Array creation
- Text conversion and substitution
- Selective printing of certain lines
- Selective deletion of certain lines
Find them all in the original Benoit’s blog post!
More Ruby one-liners:
- Smooth Ruby One-Liners list by Ryan Palo
- A very huge collection of Ruby one-liners by Sundeep Agarwal
Also, read our article about 5 Ruby methods for solving specific types of problems.