[ruby-talk:02453] Re: String#tr

From: Quinn Dunkan <quinn@...>
Date: 2000-04-11 16:11:24 UTC
List: ruby-talk #2453
> When I designed String#tr, first I thought of
> 
>   String#tr(search, replace [, flag]) where flag is for true/false to squeeze
> 
> Then I changed my mind because mere boolean flags would make programs
> harder to read.
> 
> But in the future, after keyword argument is intoduced (maybe in 1.7),
> there can be keyword options for String#tr, e.g.
> 
>   String#tr(search, replace, squeeze: true, complement: false)
> 
> Hmm, it's possible.  It remainds me Common Lisp very much though.

Keyword args are nice and all, but what I meant was:

String#tr(search, replace, String.SQUEEZE | String.COMPLEMENT)

A bit C-ish, but not so hard on the eyes even so.

In This Thread