Project

General

Profile

Actions

Feature #7998

closed

"def" should return a value (the symbol of the method name) instead of nil

Added by pmarreck (Peter Marreck) about 11 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
[ruby-core:53086]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0