I'm going through the Getting Started with Rails guide and got confused with section 6.7. After generating a scaffold I find the following auto-generated block in my controller: def index @posts = Post.all respond_to do |format| format.html # index.html.erb format.json { render :json => @posts } end end I'd like to understand how the respond_to block actually works. What type of variable is format
![Rails: How does the respond_to block work?](https://cdn-ak-scissors.b.st-hatena.com/image/square/98d6f053a97a87156775f60757c60865d0f2c47d/height=288;version=1;width=512/https%3A%2F%2Fcdn.sstatic.net%2FSites%2Fstackoverflow%2FImg%2Fapple-touch-icon%402.png%3Fv%3D73d79a89bded)