From: Gavin Sinclair Date: 2004-02-22T18:02:23+09:00 Subject: Re: Beginner here, have some questions On Sunday, February 22, 2004, 5:30:42 PM, Sang wrote: > Ruby beginner here. Heard of it before and on a whim decided to check > it out a couple of days ago and I love it. I friggin love it. > I'm doing stuff that would take me a while to figure out with other > languages' syntax. I've never seen a language that looks so "clean." > Anyway, I have some questions I couldn't find in the FAQ > sample code: > x = 2 > puts x > Now, is "puts" a class or instance method of Object? What about "x"? > Is that a class or instance variable of an Object? > When you run a Ruby program, is the program an instance of Object? Welcome. x is a local variable, as opposed to @x, @@x (instance and class), X (constant), $x (global). puts is a method of the Kernel module, which is included in the Object class, and therefore available anywhere. The context of your program is the "top-level", which is an instance of Object, and probably has some special features surrouding it. Take a look at the standard textbook "Programming Ruby" for more juicy goodness, although it seems you'll be able to pick up a fair bit on your own :) http://phrogz.net/ProgrammingRuby Cheers, Gavin