[#92063] [Ruby trunk Misc#15723] Reconsider numbered parameters — zverok.offline@...
SXNzdWUgIzE1NzIzIGhhcyBiZWVuIHVwZGF0ZWQgYnkgenZlcm9rIChWaWN0b3IgU2hlcGVsZXYp
3 messages
2019/03/31
[ruby-core:91920] [Ruby trunk Feature#4475] default variable name for parameter
From:
duerst@...
Date:
2019-03-22 00:31:14 UTC
List:
ruby-core #91920
Issue #4475 has been updated by duerst (Martin D=FCrst).
For those who want to change anything, I suggest to create new feature issu=
es. It doesn't make sense to continue discussing a closed issue.
----------------------------------------
Feature #4475: default variable name for parameter
https://bugs.ruby-lang.org/issues/4475#change-77252
* Author: jordi (jordi polo)
* Status: Closed
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: =
----------------------------------------
=3Dbegin
There is a very common pattern in Ruby:
object.method do |variable_name|
variable_name doing something =
end
Many times in fact the name of the object is so self explanatory that we d=
on't care about the name of the variable of the block. It is common to see =
things like :
@my_sons.each { |s| s.sell_to_someone }
or
Account.all.each { |a| my_account << a.money }
People tend to choose s or a because we have the class or the object name =
just there to remind you about the context. =
I would like to know if can be a good idea to have a default name for that =
parameter. I think it is Groovy that does something like:
Account.all.each { my_account << it.money } =
Where it is automagically filled and it doesn't need to be declared. =
I think it is as readable or more (for newbies who don't know what is ||) a=
nd we save some typing :)
=3Dend
-- =
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>