From: Chris White Date: 2011-11-11T05:54:24+09:00 Subject: Re: How Am I to Understand This Class Behavior? On Nov 10, 2011, at 12:39 PM, Nik Z. wrote: > ===== 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 > class definitions are expressions where the returned value is the last statement evaluated. See this irb session for example: >> result = class TestClass >> "This is a test" >> end => "This is a test" >> puts result This is a test As the last statement was "This is a test", it becomes the return of the class definition expression. - Chris (twitter: @cwgem)