Hacker News new | past | comments | ask | show | jobs | submit login

The prototypical ruby case would be:

  def some_method(x, &block)
    yield x
  end

  then to call it:

  some_method "hey" { |v| print v }
That might not look like much, but it allows you to create methods that can extend the language expressively and then use them without extra crufty syntax or sigils obstructing their meaning.



> some_method "hey" { |v| print v }

I'm sure ruby is great once you're initiated, but despite >10 years of programming and having learned basic, c, pascal, lisp, java, c++, python, perl, bash, php and javascript, I have no idea what code does.

Don't mean to harsh, just an observation.


I made that method absurdly generic, how about:

  get "/hi" do |url|
    print url
  end

?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: