As a new comer for ruby, I feel confused for this snippet: respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } end I understand that if format is .html, it will give html response and if format is .xml, it will give out xml response. So this block "do |format| ... end" is case switch like in C++. I have difficulty to understand though in ruby, if the user passing .html, as a sequential execution (notice in ruby this is not a case switch statement), what prevent ruby from executing "format.xml { render :xml => @posts }" line? To my feeling (though I know I am wrong for sure), these two lines will always be executed no matter what kind of format is passed in: format.html # index.html.erb format.xml { render :xml => @posts } Please help. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/850ffad2dfd78ca76841d64246e4f38d%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.