[#6363] Re: rescue clause affecting IO loop behavior — ts <decoux@...>

>>>>> "D" == David Alan Black <dblack@candle.superlink.net> writes:

17 messages 2000/11/14
[#6367] Re: rescue clause affecting IO loop behavior — David Alan Black <dblack@...> 2000/11/14

Hello again --

[#6582] best way to interleaf arrays? — David Alan Black <dblack@...>

Hello --

15 messages 2000/11/26

[#6646] RE: Array Intersect (&) question — Aleksi Niemel<aleksi.niemela@...>

Ross asked something about widely known and largely ignored language (on

23 messages 2000/11/29
[#6652] RE: Array Intersect (&) question — rpmohn@... (Ross Mohn) 2000/11/29

aleksi.niemela@cinnober.com (Aleksi Niemel) wrote in

[#6723] Re: Array Intersect (&) question — Mathieu Bouchard <matju@...> 2000/12/01

> >Use a hash. Here's code to do both and more. It assumes that

[#6656] printing/accessing arrays and hashes — raja@... (Raja S.)

I'm coming to Ruby with a Python & Common Lisp background.

24 messages 2000/11/30

[ruby-talk:6648] Re: Question on sort!

From: Dave Thomas <Dave@...>
Date: 2000-11-29 19:38:50 UTC
List: ruby-talk #6648
Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:

> On Wed, 29 Nov 2000, Dave Thomas wrote:
> 
> > 
> > gsub! and sub! give information that's fairly expensive to determine
> 
> But we could introduce sub? -- takes same args as sub! but doesn't change
> anything, returns true if sub would change anything, false otherwise...
> This would be less expensive than making the changes in a copy [it would
> not make the copy or the changes], since as soon as one change was found
> the thing could stop.  Similarly for sort?, gsub?, reverse?, rather than
> checking afterwards....

OK, and that's effectively what Ruby does now. However, that isn't
quite what the intent is. For example

    "cat".sub!(/../, 'do')   => dot
    "dog".sub!(/../, 'do')   => dog

Should the last one be 'nil'? If not, why not?

I come back to the point, though. Is it ever used, and if so, does it
_really_ mean that the string is unchanged, or is it taken to mean
that the pattern did not match (in which case the language already has 
constructs we can use).


Dave

In This Thread