On Wed, 17 Oct 2007 07:39:48 +0900, Randy Kramer <rhkramer / gmail.com> wrote:
> I need (or want ;-) to do something like the following:
> 
> when ((/^---\+\+ (.*)/) and (new_record == true))

When you see a case clause like this:

 case obj
 when foo
   # a
 when bar
   # b
 else
   # c
 end

Picture it like this:

 if foo === obj
   # a
 elsif bar === obj
   # b
 else
   # c
 end

(the order of arguments to === is important)

So, when you write:

> when ((/^---\+\+ (.*)/) and (new_record == true))

It's really like writing:

 if ((/^---\+\+ (.*)/) and (new_record == true)) === obj
 
... which isn't quite what you want.

Using a nested if statement might be the simplest solution.

Incidentally, it isn't usually necessary to write:

 new_record == true

If new_record is true, the result will be true anyway, and
if it is false, the result will be false anyway.  You can
just use:

 new_record

...instead.  Similarly, instead of either:

 new_record != true
 new_record == false

...you can simply write one of:

 !new_record
 not new_record

(! and not mean the same thing)

-mental