Ruby Cookbook - problem recipe


#1

Skipping through the Ruby Cookbook (Carlson & Richardson) I tried out
the
rubyTk stopwatch program, which worked fine, then tried the GTK version.
I typed it in more or less verbatim but could not run it because the
menuspec which is given as an array (see below) could not be converted
to
a string by the Gtk::ItemFactory create_items method.

Extract from the initialize method of the Stopwatch class:

menu_factory = Gtk::ItemFactory.new( 

Gtk::ItemFactory::TYPE_MENU_BAR,
‘’, nil )
menuspec = [
[
[ ‘_Program’ ],
[ ‘/Program/_Start’, ‘’, nil, nil, lambda {
start } ],
[ ‘/Program/S_top’, ‘’, nil, nil, lambda { stop
} ],
[ ‘/Program/_Exit’, ‘’, nil, nil,
lambda { Gtk.main_quit } ]
],
[
[ ‘_Reset’ ],
[ ‘/Reset/_Reset Stopwatch’, ‘’, nil, nil,
lambda { reset } ]
]
]

menu_factory.create_items( menuspec )

The error message specifies the last line here as the problem. Have I
missed something obvious? The OReilly website lists errata for the book
but nothing for page 806 where this code snippet comes from. Should I
be
looking for version mismatches in GTK2 perhaps?

Len