From: Ryan Lewis Date: 2008-05-31T06:09:59+09:00 Subject: Re: Proc multiple returns? David A. Black wrote: > On Fri, 30 May 2008, David A. Black wrote: > >>> "bar" >> def foo >> yield if block_given? # no point doing it the slow way :-) >> end >> >> p foo { ["bar", "baz"] } >> >> I have a feeling there may be something more to your question that I'm >> not seeing. > > Maybe this: > > foo { break "bar", "baz" } > > ? > > > David Almost. 'break' well...breaks it though, cause im recursively calling methods >_< Heres my original code: ----------------------- module HTML def method_missing(meth, attr={}, &block) html, attrs = "", "" attr.keys.each{ |key| attrs << " #{key.to_s}='#{attr[key]}'" if attr[key] } html << "<#{meth.to_s}#{attrs}>" html << block.call if block #yes Dave, the long way =p for now at least html << "" html end module_function :method_missing end include HTML p html { body { div(:class=>"divcls") { "IM IN A DIVLOL" } } } => "
IM IN A DIVLOL
" So far so good. But when I need multiple returns.. -------------------------------------------------- p html { body { div(:class=>"divcls") { "IM IN THE FIRST DIV" } div(:class=>"divcls") { "IM IN THE SECOND DIV" } } } => "
IM IN THE SECOND DIV
" So now I need to break convention and use: p html { body { [div(:class=>"divcls") { "IM IN THE FIRST DIV" }, div(:class=>"divcls") { "IM IN THE SECOND DIV" }] } } Which is just ugly. The CGI lib overcomes this problem but I have no idea how to make this work.. -- Posted via http://www.ruby-forum.com/.