This post originated from an RSS feed registered with Ruby Buzz
by Red Handed.
Original Post: Two new method names relevant to Range
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Matz wants good names for two new method on his blog(2005-12-10).
One is the method to check whether a Range object contains an element or not. It compares by magnitude relation.
(beg..end).foo?(x)
This method would return true if “beg <= x <= end”. In 1.8, the “include?” takes on this role. In 1.9, “include?” means containing in discrete set – except Number. Matz takes a fancy for “cover?”, but he would change his mind if you suggested him a better name. Matz likes a short name for convenient method.
Another method is one to check whether an object is conteined in the “succ” set between “beg” and “end” or not.
x.bar?(beg, end)
This method would return true if “x” were contained, and return false if “x” were not contained or “succ” could’t reach from “beg” to “end”. Other methods such as “include?” use this for efficiency. Probably, we will not use directly. So, it doesn’t matter how long the name is. This method and “between?” is alike, but “Comparable#between?” compares by magnitude relation. The new method is discrete.