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 7833127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:34:36+00:00 2026-06-02T12:34:36+00:00

When specifying a range say (‘A’..’Z’) you get the expected results A B C

  • 0

When specifying a range say (‘A’..’Z’) you get the expected results

A
B
C
...
Z

When you specify the second charcter as lower you get the range of all lower and uppercase letters. Abbreviated …

[9] pry(main)> ('A'..'z').each {|letter| puts letter}
A
B
C
...
Z
[
\
]
^
_
`
a
b
...
z

When I specify a range with a string using the same above premise I don’t get the same result. Shouldn’t a lowercase string occurred in both ranges?

[11] pry(main)> ('a'..'bat').include?('ace')
=> true
[12] pry(main)> ('A'..'bat').include?('ace')
=> false

instead I just get capitals.

[15] pry(main)> ('A'..'at').each {|letter| puts letter}
A
B
C
...
ZV
ZW
ZX
ZY
ZZ
=> "A".."at"
  • 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-06-02T12:34:37+00:00Added an answer on June 2, 2026 at 12:34 pm

    Those are two different types of ranges.

    If you ask for a range of single characters, then you get all the characters in between as defined by the character encoding (e.g. ASCII), as you saw. But if you ask for a range including strings that are longer than one character, then it no longer uses character set order.

    What happens instead is that Ruby treats each character position as a “digit”, where the set of possible digits is based on the type of character. Letters of the alphabet are grouped by case, so an uppercase “digit” will always be uppercase throughout the range; a range that starts with all uppercase letters will never contain a lowercase letter. Your range that starts at “A” will never get to “at”, but rather than continue to infinity, Ruby stops after “ZZ” because it would have to go to three characters after that, and your specified upper limit is only two characters long.

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

Sidebar

Related Questions

By specifying -lib foo.jar to ant I get the behaviour that the classes in
I'm using floats to specify texture coordinates, in the range 0-1. OpenGL likes things
When specifying a date: datetime.datetime(2011, 8, 15) How can i get to know that
I'm specifying my doctype as xhtml strict, but it's being sent over the wire
I'm specifying a color hex code as the background-color of a really long div.
I have requirement of specifying web part connections in onet.xml. So when site is
I have three tables specifying important columns below Users(Id, username) Groups(Id, groupname, creator) (creator
I know about specifying source locations using gdb. But I am wondering if there's
REST is concerned with specifying how a remote client can interface with a server,
What is the web config syntax for specifying a WCF WebService Proxy's Default Target

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.