Project

General

Profile

Actions

Backport #4578

closed

Fixnum.freeze not frozen?

Added by rbevers (Russell Bevers) over 13 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
[ruby-core:35759]

Description

=begin
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.
=end


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #6936: Forbid singleton class and instance variabls for floatClosedko1 (Koichi Sasada)08/27/2012Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0