Issue #15431 has been updated by shevegen (Robert A. Heiler).


I like the idea from one point of view - **convenience**. A bit
similar to changes such as require 'pp' being available by default;
of course it is not the same as the proposal here, since the
proposal here refers to a syntax change, whereas require 'pp'
was purely due to convenience. But from the point of view of
convenience, being able to omit "," would be nice - I actually
do sometimes forget this and then have to go to the editor
and add it, so from convenience, I like it.

Of course we can also use, at the least for Arrays, the shorthand
notations, such as %w() and so forth; then we don't need the ','.
For Hashes I believe we have no shorthand notiation, excluding
the : variant introduced some time ago; e. g. your example above
could be:

    myHash = {
      key: °»value°…,
      anotherKey: °»another value°…
    }

And it would be a bit shorter. Of course we still have to use
the ',' there.

However had I am not entirely sure if it can be so easily
added. Would this not introduce a backwards-incompatible
change? So I guess even if it were to be approved by matz
(and we don't know this as of yet), it may have to come 
way past ruby 3.0.

I don't have a problem if this is not added either, though -
while it would be convenient, I don't necessarily need it
that much. We may also have to think about code that is
mixed, such as:

  hash = {
    abc: 'abc', def: 'def'
    ghi: 'ghi',
    jkl: 'jkl'
  }

And perhaps other cases. (The ruby core team often needs 
definitions/specifications for corner cases too, since
the implementation has to include these cases too.)

Since this is coming up every now and then, I would suggest
to mention it at some developer meeting - at the least to 
hear matz' opinion about it. Because if matz does not like
the proposal then there is little point discussing it. :)

But as said, I am mostly neutral about this; only slightly
positive purely from a convenience point of view.

PS: The linked proposal is ~4 years old without much other
comments; perhaps after this may be discussed one day, we
could close down the older issues and refer to only one
of the issues, but I digress.

----------------------------------------
Misc #15431: Hashes and arrays should not require commas to seperate values when using new lines
https://bugs.ruby-lang.org/issues/15431#change-75761

* Author: nsuchy (Nathaniel Suchy)
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Ruby should not require commas for hash and array values if using new lines. I think the syntax would look cleaner without.

**Example**
~~~
myHash = {
  :key => °»value°…,
  :anotherKey => °»another value°…
}
~~~
**Could be**
~~~
myHash = {
  :key => °»value°…
  :anotherKey => °»another value°…
}
~~~

**And**
~~~
myArray = [
  1,
  2,
  3
]
~~~
Could be:
~~~
myArray = [
  1
  2
  3
]
~~~

The syntax looks a bit cleaner, with the new lines is there a need to require a comma? I look forward to hearing the community°«s thoughts on this idea :)



-- 
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>