On Mon, Jan 12, 2009 at 06:36:55PM +0100, Moritz Lenz wrote:
: Carl Mäsak wrote:
: > Jonathan (>), Ovid (>>), Larry (>>>):
: >>>> Can't say I really like the negated options though.  They smell funny.
: >>>
: >>> Agreed, but ltrim and rtrim will disappoint Israelis and dyslexics alike.
: >>>  Suggestions welcome as I can't think of anything better.
: >>
: >> The .Net framework calls 'em TrimStart and TrimEnd (and has a Trim that 
does
: >> both). So maybe trim_start and trim_end if we wanted to take that lead...
: > 
: > How about .trim(:start) and .trim(:end)?
: 
: That would be my favourite:
: 
: our Str multi method trim (Str $string:, :start = True, :end = True)

Er, that would make .trim(:start) also default :end to True...

Well, except it won't parse either.  For at least two reasons. :)

: So $str.=trim would trim both start and end, and if you want only one,
: you can say $str.=trim(:!end);.

HEY!  Don't ignore my nose.  At least, not this time. :)

Switches should almost never default to true.  It's more like:

    our Str multi method trim (Str $string:
        :$start = False,
        :$end = False,
        :$both = not $start || $end)

or really, since "start/end" really mean "startonly/endonly":

    our Str multi method trim (Str $string:
        :start($start_only) = False,
        :end($end_only) = False)
    {
            my $do_start = not $end_only;
            my $do_end = not $start_only;
            ...
    }

I really shouldn't be participating in the bikeshedding though...

Larry

Reply via email to