[#89806] [Ruby trunk Bug#15306] Generate prelude.c using miniruby — v.ondruch@...
Issue #15306 has been reported by vo.x (Vit Ondruch).
3 messages
2018/11/15
[ruby-core:89724] [Ruby trunk Feature#4475] default variable name for parameter
From:
hanmac@...
Date:
2018-11-06 14:33:14 UTC
List:
ruby-core #89724
Issue #4475 has been updated by Hanmac (Hans Mackowiak).
shevegen (Robert A. Heiler) wrote:
> The first variant, aka the variant with "x", or any other single letter, including
> "_", is something I use A LOT, and the reason is actually because it is shorter and
> simpler to type for me.
"_" is special there. it doesn't cause Syntax Error
like you can do this `iterator.each {|a, _, c, _] }`
but `iterator.each {|a, x, c, x] }` does crash
----------------------------------------
Feature #4475: default variable name for parameter
https://bugs.ruby-lang.org/issues/4475#change-74767
* Author: jordi (jordi polo)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
=begin
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 don'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 ||) and we save some typing :)
=end
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>