From: ts Date: 2002-11-19T23:03:31+09:00 Subject: Re: begin/end doesn't behave as expected For the original message, which is not in [ruby-talk] T> On Tue, 19 Nov 2002 10:25:04 GMT, Tim Bates wrote: >>Why doesn't this snippet of code do what I expect it to? >> >>out = ">out << begin >> "error.rb" >> "rules.rb" if rule.instance_of? Rule >> "dead.rb" if rule.instance_of? DeadRule >> "proposals.rb" if rule.instance_of? Proposal >> page.to_s unless page.nil? >>end The block return the value of the last expression which in this case is page.to_s unless page.nil? i.e. unless page.nil? page.to_s else nil end because probably (???) page is nil, it return the value of the `else' part >>>>> "T" == Tim Hunter writes: T> I think a case statement will do what you want here.. yes Guy Decoux