README.markdown

The Ampex (&X) library provides a Metavariable X that can be used in conjunction with the unary ampersand to create anonymous blocks in a slightly more readable way than the default. It was inspired by the clever Symbol#to_proc method which handles the most common case very elegantly, and discussion with Sam Stokes about creating lazy enumerators in ruby.

Usage

At its simplest, &X can be used as a drop-in replacement for Symbol#to_proc:

[1,2,3].map &X.to_s
# => ["1", "2", "3"]

However the real strength in the library comes from allowing you to call methods with arguments:

[1,"2",3].select &X.is_a?(String)
# => ["2"]

And to chain method calls:

[1, 2, 3].map &X.to_f.to_s
# => ["1.0", "2.0", "3.0"]

As everything in Ruby is a method call, you can create readable expressions without the noise of a one-argument block:

This library is copyrighted under the MIT license, see LICENSE.MIT for details.

Backwards compatibility breakages

Between version 1.2.1 and version 2.0.0, the support for assignment operations was removed from
ampex. These had a very non-obvious implementation, and it was impossible to support
assigning of falsey values; and did not work on rubinius.

Between version 2.0.0 and 3.0.0 Metavariable#=== was implemented to provide case statement
support. This will break code that was expecting &(X === foo) to work.