Project

General

Profile

Feature #16095

2 Features: remove (simplify) 'new' keyword and Property Shorthand

Added by D1mon (Dim F) 12 months ago. Updated 8 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:94254]

Description

common use:

class A
  def initialize(arg1, arg2)
    @arg1 = arg1
    @arg2 = arg2
  end
end
A.new(1,2)

1) feature: remove 'new' keyword:

A(1,2) # shorter and more comfortable

2) feature: Property Shorthand (like ES6)

class A
  def initialize(arg1, arg2)
    # shorter and more comfortable
    @arg1, @arg2
    # or this:
    @arg1
    @arg2
  end
end

So as not to duplicate the code (words). May need to do some other syntax or character (:arg1, ^arg1, %arg1, ...)

can also be applied to other types.

Hash example:

a = 1
b = 2
h = {a:a,b:b} # common use
h = {a,b} # new syntax or {%a,%b} - any syntax of your choice

Related issues

Related to Ruby master - Feature #11105: ES6-like hash literalsRejectedActions

Also available in: Atom PDF