String Ranges

  • Thread starter trans. (T. Onoma)
  • Start date
T

trans. (T. Onoma)

I wonder if any one has ever noticed the "order" discrepancy that exists
between String#<=> and String#succ. One consequence:

irb(main):001:0> a = 'a'..'b'
=> "a".."b"
irb(main):002:0> a.include?('aa')
=> true

Also I'd like to know what others are doing with string ranges. If you've used
a string range in a serious way I'd like to know how --I'm trying to get a
impression of their over all usability.

Thanks,
T.
 
D

David A. Black

Hi --

I wonder if any one has ever noticed the "order" discrepancy that exists
between String#<=> and String#succ. One consequence:

irb(main):001:0> a = 'a'..'b'
=> "a".."b"
irb(main):002:0> a.include?('aa')
=> true

I think that I've seen examples like this brought up occasionally:

irb(main):007:0> 'z'.succ > 'z'
=> false

:)
Also I'd like to know what others are doing with string ranges. If you've used
a string range in a serious way I'd like to know how --I'm trying to get a
impression of their over all usability.

I've mainly used them for:

('a'..'z').to_a

and similar things.


David
 
L

Logan Capaldo

Ever once in a while I'll do a ('a'..'z').each { } type dealie, can't
remember why at the moment. (Of course this can be achieved with
to_a.each { } to)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

dirty ranges 9
Coercion and ranges 5
string decrement 0
Fun with ranges! 3
Open-ended ranges? 14
using multiple ranges 0
trans string into array 4
How to try a range of hex values in C# code ? 0

Members online

Forum statistics

Threads
474,161
Messages
2,570,891
Members
47,423
Latest member
henerygril

Latest Threads

Top