From: Marc-Andre Lafortune Date: 2009-06-02T08:03:11+09:00 Subject: [ruby-core:23665] Re: [Bug #1550] String#lstrip! raises RuntimeError on Frozen String Despite Making No Changes I couldn't agree more! I'd find it most surprising if [1,2,3].freeze.sort! didn't raise an error! On Mon, Jun 1, 2009 at 6:07 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:23657] [Bug #1550] String#lstrip! raises RuntimeError on Frozen String Despite Making No Changes" > � �on Mon, 1 Jun 2009 20:13:49 +0900, Run Paint Run Run writes: > > |Calling String#lstrip! on a frozen string raises a RuntimeError even if the string was not changed. String#rstrip! doesn't raise an exception in this scenario. I believe that the latter behaviour is correct; #lstrip! should only raise a RuntimeError if the string would be changed. > > I admit the inconsistency. �There could be two policies: > > �(a) methods should raise RuntimeError only when actual changes are > � � made, because it should detect changes. > > �(b) methods should eagerly raise RuntimeError when they could > � � possibly make changes, to detect modify attempt to frozen > � � strings (that most likely caused by bugs) earlier. > > Currently both policies mixed. �You've suggested the former, I'd > rather prefer the latter. �Any opinion? > > � � � � � � � � � � � � � � � � � � � � � � � � � � � �matz. > >