Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Superators: Add new operators to Ruby

By Peter Cooper / August 30, 2007

Superators

I know there's going to be some controversy around this clever piece of code by Jay Phillips. He's developed "Superators", a library that finally makes it easy to create new operators within Ruby that look like line noise. Always wanted a "-~+~-" or "===~-+~++" operator? Now it's within your grasp! As Aleks Clark says: "Job security and spiffy DSL construction in one neat package."

Comments

  1. andrew says:

    I like it. We'll finaly be able to increment integers like i++.
    (Not that it's that hard to do i+=1)

  2. Chris says:

    Actually, superators are still binary operations, so the unary increment/decrement operators still won't work (I tried).

  3. Sean says:

    Ok, now this is silly. It sounds very useful, but this is exactly the kind of thing developers love to abuse. (I say this as I download it. ;-)

  4. Shadowfiend says:

    Yeah, it turns out this is written in pure Ruby (no C), so it doesn't actually *add* operators, it just reuses the existing ones in a very very interesting way.

  5. Markús says:

    What's all i++? I already have i.next or i.upto. I think somebody miss the point of ruby language...

Other Posts to Enjoy

Twitter Mentions