Forum: Ruby Re: string slice elegant way

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Pena, Botp (Guest)
on 2006-03-04 02:41
(Received via mailing list)
Mage [mailto:removed_email_address@domain.invalid]

#a = 'hello there'
#and I need 'llo there'
#a[2,a.size] works, but I find it ugly because the given length
#is larger
#than the real length of the result.
#a[2,a.size - 2] is okay, but it is not DRY.
#Is there any elegant way, like a[2:] in Python?

is a[2..-1] good enough?
Peter E. (Guest)
on 2006-03-04 07:43
(Received via mailing list)
this is the closest I could think of:

a = "hello there"
> llo there
This topic is locked and can not be replied to.