From: Robert Klemme Date: 2007-10-17T15:05:02+09:00 Subject: Re: Compound conditionals in case when statements? Syntax? On 17.10.2007 01:37, Michael Fellinger wrote: > On 10/17/07, Randy Kramer wrote: >> I need (or want ;-) to do something like the following: >> >> when ((/^---\+\+ (.*)/) and (new_record == true)) >> >> I've tried a lot of variations, but either this just won't work, or I haven't >> managed to guess the proper syntax. (I've also tried googling and searching >> in the pickaxe(2).) >> >> Aside: Maybe the compound won't work because one is what the pickaxe calls a >> condition and the other is a comparison? But, I'm not sure which is which. >> >> If this can't work, I'll try (I've been trying) a nested if statement, but >> I'll ask about that in my next post. ;-) > > this can't work for the simple reason that the objects given at 'when' > are being sent the === message with the object in 'case'. In your > 'when' it's the result of the stuff in closures. > This generally is the job of 'if', just keep in mind that case/when is > for matching, if/else is for conditionals. See Pena's comment: there is another form of 'case' which can be nicely used to solve this. Kind regards robert