From: Motohiro KOSAKI Date: 2012-02-08T05:39:01+09:00 Subject: [ruby-core:42414] [ruby-trunk - Feature #4172][Rejected] Named arguments/parameters support Issue #4172 has been updated by Motohiro KOSAKI. Status changed from Assigned to Rejected Current trunk (for 2.0) has a keyword argument feature. Please look at and give us comments. Thanks. ---------------------------------------- Feature #4172: Named arguments/parameters support https://bugs.ruby-lang.org/issues/4172 Author: Rodrigo Rosenfeld Rosas Status: Rejected Priority: Low Assignee: Yukihiro Matsumoto Category: Target version: =begin It is usual in the Ruby community to use the idiom def method(options={}) param1, param2 = options.values_at(:param1, :param2) # or {param1: 'default1', param2: 2}.collect{|k, v| options[k] || v } ... end instead of def method(param1, param2) ... end Perl 6 supports named arguments (or parameters) out-of-the-box. Suppose the following method (not valid Ruby actually): def tag(tag_name, :content(''), :attributes({}), :closing_tag(true)) ... end It would be great if this could be called as hr = tag('hr', closing_tag -> false, attributes -> {style: 'color: blue'}) It think it should be even possible to call it like tag(tag_name: 'div', content: 'Ruby is getting even more awesome with this feature!') I think it is much more legible than tag('hr', '', {}, false) or than using an 'options' hash parameter. Is there any reasons why Ruby doesn't support named parameters as part of the syntax? =end -- http://bugs.ruby-lang.org/