Some suggestions

Dear,

I have two suggestions which I think would be useful in ruby.

First of all, I have noted that a sleeping thread (a thread that was
..stop'ed) does no longer have the method .stop... This means that one
must use
thread.stop unless thread.stop?
I would suggest implementing a stop method on a sleeping thread that is
basically a noop.

Secondly, I have noticed that the strip/lstrip/rstrip methods of String
do not take a string with the possible characters to remove. Possibly
this could be changed, and then have as default value " ". What I mean
is:

"aaabbbccc".lstrip("ab") => "ccc"
"abababccc".lstrip("ab") => "ccc"
"ababcabc".lstrip("ab") => "cabc"

Similarly for strip and rstrip.

With regards,
Christophe

Hi,

At Tue, 13 Sep 2005 13:01:32 +0900,
christophe.poucet@gmail.com wrote in [ruby-talk:155872]:

First of all, I have noted that a sleeping thread (a thread that was
..stop'ed) does no longer have the method .stop... This means that one
must use
thread.stop unless thread.stop?

There's no such method Thread#stop. Threads can stop only
current thread itself.

···

--
Nobu Nakada

Dear,

I have two suggestions which I think would be useful in ruby.

First of all, I have noted that a sleeping thread (a thread that was
.stop'ed) does no longer have the method .stop... This means that one
must use
thread.stop unless thread.stop?
I would suggest implementing a stop method on a sleeping thread that
is basically a noop.

Secondly, I have noticed that the strip/lstrip/rstrip methods of
String do not take a string with the possible characters to remove. Possibly this could be changed, and then have as default value " ". What I mean is:

"aaabbbccc".lstrip("ab") => "ccc"
"abababccc".lstrip("ab") => "ccc"
"ababcabc".lstrip("ab") => "cabc"

"aaabbbccc".sub /^[ab]+/, ''

=> "ccc"

"abababccc".sub /^[ab]+/, ''

=> "ccc"

"ababcabc".sub /^[ab]+/, ''

=> "cabc"

Similarly for strip and rstrip.

#strip
gsub /[ab]+/, ''

#or

"ababcabc".tr "ab", ""

=> "cc"

#rstrip
sub /[ab]+$/, ''

Does this help?

    robert

···

christophe.poucet@gmail.com wrote:

Indeed, I noticed that too late. So please disregard the comment about
Thread. On the other hand, I do think that the extension to the
different strip methods would be useful.

With regards,
Christophe

Yip, thank you :slight_smile:

Isn't #strip for leading/trailing only? (A combined lstrip and rstrip, if you will.)

So:
gsub /^[ab]+|[ab]+$/, ''

···

On Sep 13, 2005, at 12:31 AM, Robert Klemme wrote:

#strip
gsub /[ab]+/, ''

Gavin Kistner wrote:

···

On Sep 13, 2005, at 12:31 AM, Robert Klemme wrote:

#strip
gsub /[ab]+/, ''

Isn't #strip for leading/trailing only? (A combined lstrip and
rstrip, if you will.)

So:
gsub /^[ab]+|[ab]+$/, ''

Right! Thanks for the correction.

    robert