On Tue, 01 Jul 2003 09:50:31 +0900, Ian Macdonald wrote: > class << Foo > .. > end > > I'm having a hard time understanding the books and figuring out when I > might actually want/need to use this. I use this construction most when im doing unittesting, in order to access members I otherwise don't have permission to access. def test_macro2 m = FakeMementoBig.new ct = FakeCaretaker.new(m) class << ct attr_reader :record_mode end ct.macro_begin assert_equal(true, ct.record_mode) ct.execute_undo assert_equal(false, ct.record_mode) assert_exception(FakeCaretaker::Nothing2Redo) { ct.execute_redo } assert_exception(FakeCaretaker::Nothing2Undo) { ct.execute_undo } end Another place I use it, is for building menues: def build_menu_bottom menu = [ "1", "Record", " 2", "Play", " 3", "Undo", " 4", "Redo", " 5", "S.Left", " 6", "S.Down", " 7", "S.Up", " 8", "S.Right" ] class << menu def slice2 until empty? yield(*slice!(0, 2)) end end end res = [] menu.slice2 do |sep, text| res += sep.to_cells(Cell::MENU_SEP) + text.to_cells(Cell::MENU) end res end -- Simon Strandgaard