From: Yukihiro Matsumoto Date: 2006-02-16T10:01:26+09:00 Subject: Re: why does this freeze not work? Hi, In message "Re: why does this freeze not work?" on Thu, 16 Feb 2006 09:48:28 +0900, "konsu" writes: |i need to set an instance variable in my object once and make sure this |variable is not changed afterwards. i tried the code below which i expected |to fail with a TypeError but it happily outputs '2'. i kind of understand |why it succeeds, i think it just creates another @id when i call id=() |method, but is there a way to do what i want to do? No. You have frozen a Fixnum object 1, not @id. Instance variables are attributes of an object, not objects by themselves. You have to freeze whole object C, or use attr_reader instead of attr_accessor. matz.