On Wed, Apr 27, 2005 at 10:30:35AM -0600, Paul Seamons wrote:
> Minor note.
> 
> Would you want this:
> 
> >    sub &infix:<myeq>(Str $a, Str $b) { return ($a eq $b) ? $a : ''; }
> 
> to be:
> 
>    sub &infix:<myeq>(Str $a, Str $b) { return ($a eq $b) ? $a but bool::true: 
> ''; }
> 
> (Is that the right way to do it ?)

Firstly, everybody needs to remember that ?: is now ??::   :-)

And yes, if $a and $b are equal but evaluate to a false value, you
probably want to attach some truthfulness to the value for boolean
sake.  I wonder if you shouldn't also return a bool::false for the
other case just to be explicit:

    sub &infix:<myeq>(Str $a, Str $b) { 
        return ($a eq $b) ?? $a but bool::true :: bool::false
    }

Suddenly I'm suffering a visual overload of colons though.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to