Hi
I want to „count“ a string. I don’t know, how to express it better,
because of that I’ll try to explain it. I have a string, say ‘a’. Now
I want to increase it, so it would be ‘b’. I increase it again, it
would be ‘c’ and so on.
Is there a method for this task?
On 02/26/2010 14:30, Benedikt Müller wrote:
Hi
I want to „count“ a string. I don’t know, how to express it better,
because of that I’ll try to explain it. I have a string, say ‘a’. Now
I want to increase it, so it would be ‘b’. I increase it again, it
would be ‘c’ and so on.
Is there a method for this task?
Try:
“a”.succ
=> “b”
Regards
irb
x=‘a’
=> “a”x.next!
=> “b”x.next!
=> “c”x.next!
=> “d”x.next!
=> “e”x.next!
=> “f”
thx
Sorry I looked in ruby-doc in the String class but I didn’t saw it so
I thought that isn’t in the standard lib.
Is there a possibility to say what chars can be in the string? I want
to have upper chars and lower chars but i want to start with only one
char.