5 ms·
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 lo
by 0x44 17y ago
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.
- mclin 17y ago> 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.
- 0x44 17y agoI made that method absurdly generic, how about: get "/hi" do |url| print url end ?