From: Russell Bevers Date: 2011-04-27T01:09:12+09:00 Subject: [ruby-core:35906] [Ruby 1.8 - Bug #4578] Fixnum.freeze not frozen? Issue #4578 has been updated by Russell Bevers. BTW, freeze & frozen? work fine on Fixnums in 1.9.x on my platform. I agree that it seems unnecessary to correct in 1.8.x. I can move to 1.9. ---------------------------------------- Bug #4578: Fixnum.freeze not frozen? http://redmine.ruby-lang.org/issues/4578 Author: Russell Bevers Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: - Using ruby 1.8.7 p334 a = 5; a.freeze Expect: true == a.frozen? Result: false == a.frozen? I realize Fixnum is already immutable, however consider the following code: class Demanding attr_reader :important def initialize(important) @important = important @important.freeze end end Demanding wants to be able to rely on identifier not changing over its lifespan. I could make it demanding with some other mechanism such as: * Force important to be a particular type * Force important to respond_to? particular messages during initialization These are all slippery and don't address the concern of mutability of important objects. Freeze seemed like the obvious solution, but it's probably best for me to just take a deep copy of important for Demanding's own use. In the meantime, I thought I should share that freeze is not working for all objects in Ruby 1.8.7 p334. -- http://redmine.ruby-lang.org