From: Kero Date: 2006-01-04T21:17:57+09:00 Subject: Re: Understanding the fundamentals, methods. (from Pickaxe book) > I'd just like to check that the following uses methods and that no classes > or instance variables are created. I see that there are no > @instance_variables.. > > Where's the object? try ruby -e 'p self' (as if executing a ruby file containing "p self" and nothing else) it prints "main". Apparently the object sees itself as main. ok. > What class is being used? do ruby -e 'p self.class' it prints "Object" so main is an Object. tadaa! (actually, it is a bit more than "just" an Object, but you can figure that out yourself when you learn about Modules and mixin) What should you learn from this? Everything is an object. Really. But if you want to do some simple procedural stuff, the objects do not get in your way. They can be, as you experienced, completely invisible. That's one of many, many reasons I like Ruby so much :) > Am I correct in saying that say_goodnight is a method, where (name) is the > parameter for it? absolutely correct > #!/usr/bin/ruby > # Tue Dec 27 15:42:59 GMT 2005 > # from page 13 of the pick-axe book > def say_goodnight(name) > "Good night, #{name.capitalize}" > # we use the output of the last result - this save time > end [snip]