http://ruby-doc.org/docs/ProgrammingRuby/html/classes.html

Check out the 'Class and Module Definitions' section.

-Jingjing


-----Original Message-----
From: Nik Z. [mailto:esperantoca / gmail.com] 
Sent: Thursday, November 10, 2011 12:40 PM
To: ruby-talk ML
Subject: How Am I to Understand This Class Behavior?

Hi, Gurus,

   The following code gets me wondering: how come the last "puts" gets
printed without initializing on the Foo class at all...

   I would appreciate it if anyone can explain this to me.  Thank you in
advance !!!


Nik
===== Code as Below =======
#/usr/bin/env ruby

puts "print as expected"

def bar
    puts "Hello, World!"
end

class Foo
    def initialize
    end

    puts "How does this get printed without Foo.new???"
end

-- 
Posted via http://www.ruby-forum.com/.