From: Jani Monoses Date: 2004-09-20T22:12:54+09:00 Subject: Re: methods with and without ! Robert Klemme wrote: >"Jani Monoses" schrieb im Newsbeitrag >news:414EC550.2040700@iv.ro... > > >>Hello >> >>what is the criterion for methods to have a ! terminated variant in the >>standard ruby APIs? >>For instance in String strip has a receiver-modifying counterpart but >>ljust does not. >>Is it that the result fits in the same memory? (strip returns a string >>at most as long as the original while just can return a much longer one) >> >> > >Normally the rule is that the method modifies the current instance as >opposed to the creation of a new instance (e.g. String#gsub! and >String#gsub). But that convention is not followed consistently in the std >lib. I guess the explanatory text contains "historic reasons" somewhere. >:-} > > > maybe it was my bad wording ;) I know that ! versions modify in place (scheme heritage?) I was asking which methods should have a ! variant along the regular one. We have sub and sub!, strip and strip! but no String#just! only String#just Does in-place imply then that no memory allocation will be done and the result must fit in the calling object? Jani Jani