David A. Black wrote: >> | Similarly, it's true that a class and its objects are "related" -- but >> | that doesn't mean that any feature or even nuance of language design >> | where they behave separately has to be or should be removed. There's >> | ample room inside class definitions to do all the things you're >> | talking about, going through conventional, "polite" channels: >> | >> | class C >> | def x >> | @x ||= 10 >> | end >> | end >> >> "Polite"? Bull-hockey. That is a hack! > > It strikes me as a perfectly idiomatic way of writing a "getter" > method with a default value. I call it "polite" because it sets up a > situation where what will happen is that the object will be sent a > message and handle it. While I have not followed the whole discussion the above can be quite a burden when you're writing lots of methods that use the same instance variables that may not yet by initialized. In that case you will have to call a method ensure_initialized() or similar that sets all instance variables to default values if they were not yet set and call that from every other method. I don't know if there is a better way, but I'd certainly like to have one...