The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Two new method names relevant to Range

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Two new method names relevant to Range Posted: Dec 20, 2005 9:42 AM
Reply to this message Reply

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
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

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.

Please see the thread: [ruby-talk:167182]

Read: Two new method names relevant to Range

Topic: Qt 4.1 and QtRuby Previous Topic   Next Topic Topic: More (or less?) spreadsheet stuff

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use