On Tue, Jun 19, 2012 at 10:12 PM, Hal Fulton <rubyhacker / gmail.com> wrote: > >> > Freezing an object also reduces its contract. >> >> Kind of. =A0But I consider that a special case because freeze prevents >> all mutations but not other operations. =A0It also does not restrict the >> range of valid state - it just freezes it. > > Hmm. If a Symbol is-a frozen String, how does that reduce the range > of valid state any more than a "real" frozen String? Freezing does _not_ reduce the state, which is what I said above. With inheritance Symbol is-a String - not "frozen String". If at all the inheritance would be the other way round: a String is-a Symbol and it would extend the contract by mutating methods. > What operations > other than mutations are prohibited? For example: String has method << which is part of the public contract and that will be broken by _all_ Symbol instances. So you give someone something and say "this is a String" but in reality it is not because all instances lack many of the functionality of String. While with actually freezing Strings << works most of the time and there are just some instances which are in a state (frozen) which does not allow successful execution of the method. Kind regards robert --=20 remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/