In Ruby 1.9, you can have Fixnum , Float and Symbol values ββthat are thawed or frozen:
irb(main):001:0> a = [ 17, 42.0, :foo ]; a.map(&:frozen?) => [false, false, false] irb(main):002:0> a.each(&:freeze); a.map(&:frozen?) => [true, true, true]
I understand the usefulness of freezing strings, arrays, or other mutable data types. However, as far as I know, instances of Fixnum , Symbol and Float immutable from the start. Is there any reason to freeze them (or for some reason that Ruby will not report them as already frozen?
Note that in Ruby 2.0, Fixnum and Float both start as frozen, and Symbol retains the behavior described above. So, he slowly becomes "better" :)
Phrogz
source share