From: "gcao (Guoliang Cao)" Date: 2013-03-09T13:11:19+09:00 Subject: [ruby-core:53252] [ruby-trunk - Feature #7998] "def" should return a value (the symbol of the method name) instead of nil Issue #7998 has been updated by gcao (Guoliang Cao). This is a nice addition indeed and I remember I asked for it too in the past. One usage could be method annotation like what is done in some command line library: desc 'Do something' def do_something ... end The above code looks nice but I believe its underlying code involves using method_added and is fragile when method_added is also used for other functionalities. If def returns method name, then a comma is all we need to remove the meta-programming complexity. desc 'Do something', def do_something ... end I really wish one day this will be added to Ruby. ---------------------------------------- Feature #7998: "def" should return a value (the symbol of the method name) instead of nil https://bugs.ruby-lang.org/issues/7998#change-37412 Author: pmarreck (Peter Marreck) Status: Open Priority: Normal Assignee: Category: Target version: next minor The C code that implements Ruby method definitions already creates a symbol corresponding to the method name. I propose that the "def... end" block returns this symbol. This would allow the following elegant Ruby code: protected def foo(); end private def bar(); end since "protected" and "private" already take symbol arguments. I estimate that this would be extremely easy to implement while creating extremely minimal existing code impact. I proposed this idea to the #ruby IRC channel on freenode.net and it was received very well, they encouraged me to file this ticket! Thank you for considering. -- http://bugs.ruby-lang.org/