Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6976801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:32:37+00:00 2026-05-27T17:32:37+00:00

I was trying to find out how to create Ranges from custom objects in

  • 0

I was trying to find out how to create Ranges from custom objects in Ruby. I am very new to Ruby and I found the documentation on Range not to be helpful.

The error I was receiving when trying to create a Range from my objects was simply “Bad Value For A Range”.

I eventually figured out after far to long, that in order to create a range from my object, I must define the “succ” and “<=>” functions.

My question is this. Is there a good resource that would have told me that I needed to define the above 2 functions in order to use my object in a range? I’d like to avoid problems like this in the future.

Sorry for the unconventional question. Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:32:37+00:00Added an answer on May 27, 2026 at 5:32 pm

    The Pickaxe Book (AKA “Programming Ruby”) has this to say about Range:

    So far we’ve shown ranges of numbers and strings. However, as you’d expect from an object-oriented language, Ruby can create ranges based on objects that you define. The only constraints are that the objects must respond to succ by returning the next object in sequence and the objects must be comparable using <=>, the general comparison operator.

    Emphasis mine. You have to be careful though, the Pickaxe that you’ll find online is rather old and sometimes it doesn’t agree with the current state of Ruby. There is an updated version for Ruby 1.9 but I don’t think that one is freely available online so you’d have to buy a copy.

    I usually end up digging through the Ruby source to figure out a lot of these things. That applies doubly so to Rails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to find out a good JavaScript library that can create a nice
I'm trying to find out how they were able to create this site. http://www.cpeople.ru
I am trying to find out how to upload a file from a web
I am trying to find out how much memory my application is consuming from
I'm trying to find out how much memory my objects take to see how
I am trying to find out why the code below does not seem to
I'm new to jquery and i'm trying to find out if it's possible to
Completely new to Objective-C, trying to find out when I need to alloc and
I'm new to Objective-C, and I'm trying to find out the best way to
I am trying to find out MAC address and I managed to create working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.