Hi,

Am Freitag, 30. Okt 2009, 13:25:05 +0900 schrieb Michael W. Ryder:
> Michael W. Ryder wrote:
>> Just Another Victim of the Ambient Morality wrote:
>>>     I'm actually hoping this is an embarrassing question but how do you 
>>> get the tail end of a string?  All I've figured out is this:
>>>
>>> index = 4
>>> string[index, string.size - index]
>>>
>>>     ...but surely there's a better way.
>>>
>> You mean like string[-1]?
>
> I'm sorry, I missed the part about the index number of characters.  Try 
> string[-index, index].

That's really ugly. You shouldn't have to mention `index' twice.
I would even support a language extension to solve this problem.

For my private use I wrote a suite of methods

  String#head
  String#tail
  String#starts_with
  String#ends_with

Probably I should make an own gem of it. I'll think about that
this weekend. For so long have a look at my personal library:

  http://bertram-scharpf.homelinux.com:8808/doc_root/bs-ruby-2.7/rdoc/classes/String.html

By the way: Still I'm convinced that there should be a
`String#notempty?' method corresponding to `Numeric#nonzero?'.

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de