Project

General

Profile

Actions

Feature #16095

closed

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

Added by D1mon (Dim F) over 5 years ago. Updated almost 5 years ago.

Status:
Rejected
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
  1. 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 1 (0 open1 closed)

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0