Feature #5006

Allow ~> as a method

Added by trans (Thomas Sawyer) about 9 years ago. Updated over 8 years ago.

Target version:


It occurs to me that since RubyGems uses ~> as a recognized version constraint operator (along with >, <, >= and <=) it would be nice if Ruby supported it as a valid method. Ultimately RubyGems could use the new method in it's code. But more generally it could be useful too, as it has a couple of nice features, namely the '~' part can be thought of as meaning "approximate", and as a whole it looks like a pointing arrow.

Updated by mame (Yusuke Endoh) over 8 years ago

  • Status changed from Open to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)

Updated by mame (Yusuke Endoh) over 8 years ago

  • Status changed from Assigned to Rejected


This syntax would bring ambiguity.
Consider "0.~>1". This can parse as:

0.send("~>", 1)

as well as:

0.send("~") > 1

. So I close this ticket as Rejected.

There are some incomplete or arguable points in this proposal.

  • Doesn't Ruby define builtin Integer#~> ? And what's the behavior?
    If Ruby does not provide Integer#~>, this feature will encourage
    users to define their own Integer#~>, which will bring collision
    and confusion.

  • An inversion method <~ will be needed. This also brings additional
    parsing ambiguities.

  • The looking is awkward with Japanese font, because a tilde character
    is printed as superscript ;-)

Yusuke Endoh

Also available in: Atom PDF