Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't believe the second one works. Usually you'd define a method using:

  def some_method
    # do something
  end
Usually you'll only use do after a method that's already defined, in order to pass a block of code to it.


You are correct:

    ruby-1.9.2-p0 > def something; "hey" end
     => nil 
    ruby-1.9.2-p0 > something
     => "hey" 
Adding the do makes it not work. def doesn't have a do.




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

Search: