Arc Forumnew | comments | leaders | submitlogin
8 points by jnl 6169 days ago | link | parent

Ruby can be even more concise:

  def said
    aform(input("foo"), submit) {
      w_link("click here") {
        "you said: #{arg :foo}"}}
  end
Support code here: http://arc-challenge.heroku.com/


1 point by jnl 6169 days ago | link

Interestingly, you can control which binding is passed to which transaction. Let's say you wanted to show the form twice, and display the answers in reverse order. So something like this:

Display the form to collect answer1 (still named foo), on submit display the form again to collect answer2 (also named foo), then the "click here" page, then a page with "you said: [answer2]" and a "click here" link, then a page with "you said: [answer1]".

How do you do that in Arc? In this Ruby example, it would be:

  def said
    aform(input("foo"), submit) {
      aform(input("foo"), submit) {
        msg = "you said: #{arg :foo}"
        w_link("click here") {
          "you said: #{arg :foo}<br />" + w_link("click here") {
          msg}}}}
  end

-----