From: Rick DeNatale Date: 2010-10-04T22:09:54+09:00 Subject: Re: Object.object.method() Alors! GTK ne parle pas français? And in Ruby 1.9 you could spell it properly as fenêtre, but it would still cause a "No Method" error. On Mon, Oct 4, 2010 at 5:49 AM, Jean-Julien Fleck wrote: > 2010/10/3 Johan Soderholm : >> Hello, obviously it's a time for a noobie question. What the following >> statement means? >> >> Object.object.method() >> >> Sample code: >> >> window = Gtk::Window.new(Gtk::Window::TOPLEVEL) >> area = Gtk::DrawingArea.new() >> area.window.set_cursor(Gdk::Cursor.new(Gdk::Cursor::PENCIL)) >> >> I'm confused. Can anyone enlight me? > > To complete Rick's answer, the "window" in the last line has > (normally) *nothing* to do with your window variable. Ruby sees that > you are trying to talk to the object "area" (because of the dot) so it > politely ask "area" if it has a method named "window" (which I assume > it has). You could try > > fenetre = Gtk::Window.new(Gtk::Window::TOPLEVEL) > area = Gtk::DrawingArea.new() > area.window.set_cursor(Gdk::Cursor.new(Gdk::Cursor::PENCIL)) > > it should still work (assuming you change all the other occurence of > *variable* "window" into "fenetre") > > On the contrary, the code > > fenetre = Gtk::Window.new(Gtk::Window::TOPLEVEL) > area = Gtk::DrawingArea.new() > area.fenetre.set_cursor(Gdk::Cursor.new(Gdk::Cursor::PENCIL)) > > should not work: ruby should complain with a "NoMethodError" > > Cheers, > > -- > JJ Fleck > PCSI1 Lycée Kléber > > -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale