"Florian Gross" <flgr / ccan.de> schrieb im Newsbeitrag
news:2j7p3jFt323lU1 / uni-berlin.de...
> Moin!

Moin moin!

> Some oddities I noticed:
>
> irb(main):034:0> File.open("C:/autoexec.bat").freeze.inspect
> TypeError: can't modify frozen File # inspect doesn't modify
>          from (irb):34:in `inspect'
> # This one also happens for File#path etc.

IMHO an IO instance can't really be frozen in a meaningful way because it
must maintain changing state (namely the stream position).  Maybe
IO#freeze should throw an exception ("illegal operation", "cannot freeze"
or similar).

> irb(main):063:0> Dir.new(".").freeze.send(:initialize, "C:/").read
> => "katapult.zip" # Initialize executed despite Dir being frozen

I would not regard this a bug since initialize is expected to change the
instance, isn't it?

> irb(main):097:0> Class.new.freeze.to_s
> TypeError: can't modify frozen object # to_s doesn't modify
>          from (irb):97:in `to_s'

That's really surprising.  Maybe it's due to lazy initialization of the
class's name.

Btw, do people frequently use #freeze?

Kind regards

    robert