From: Bertram Scharpf Date: 2009-10-31T01:40:22+09:00 Subject: Re: How do you get the tail end of a string? Hi, Am Samstag, 31. Okt 2009, 00:12:01 +0900 schrieb Marnen Laibow-Koser: > Bertram Scharpf wrote: > > Am Freitag, 30. Okt 2009, 13:25:05 +0900 schrieb Michael W. Ryder: > >> string[-index, index]. > > > > That's really ugly. You shouldn't have to mention `index' twice. > > And you don't. string[-index..-1] does the trick. > > > I would even support a language extension to solve this problem. > > No need. You seem to be quite sure what you need. Look at this: irb(main):001:0> def timer ; start = Time.now ; yield ; Time.now - start ; end => nil irb(main):002:0> index = 2 => 2 irb(main):003:0> timer do 100_000.times { "hello"[-index..-1] } end => 0.888826 irb(main):004:0> timer do 100_000.times { "hello".tail index } end => 0.21357 Your calculation needs more than four times as much processor time. Don't you need to save time? Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de