From: Tim Hunter Date: 2002-11-19T22:29:21+09:00 Subject: Re: begin/end doesn't behave as expected 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 >out << "\">" + rule.to_s + "" > >I expect the begin/end block to evaluate to one of page.to_s, >"proposals.rb", "dead.rb", "rules.rb" or if all else fails "error.rb" but >instead it seems to evaluate to nil, and I get "TypeError: failed to >convert nil into String". > >Tim Bates I think a case statement will do what you want here..