Project

General

Profile

Actions

Feature #12578

closed

Instance Variables Assigned In parameters ( ala Crystal? )

Added by lankford (Matt Lankford) over 7 years ago. Updated over 6 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:76329]

Description

When I first saw the instance assignments in Crystal, I was floored... I have looked at all 18 pages in this tracker and thought it "must" have been mentioned in here... but I don't see it... pardon me if I missed it...

BUT

so in Crystal, this :

class MyStuff

  def initialize @thing_one , @thing_two
  end

end

would replace :

class MyStuff

  def initialize thing_one , thing_two
    @thing_one = thing_one
    @thing_two = thing_two
  end

end

One of the things I loved about ruby was attr_accessor / reader / writer...

I know in Crystal, it is a macro, but still at the millions of lines of boilerplate that would go away...

Has no one thought of stealing this from Crystal or is there a good reason this does not exist? ( and I will go sit down and color now )


Related issues 4 (2 open2 closed)

Is duplicate of Ruby master - Feature #5825: Sweet instance var assignment in the object initializerAssignedmatz (Yukihiro Matsumoto)Actions
Is duplicate of Ruby master - Feature #8563: Instance variable argumentsRejectedmatz (Yukihiro Matsumoto)Actions
Is duplicate of Ruby master - Feature #12023: Allow ivars to be used as method argumentsOpenActions
Has duplicate Ruby master - Feature #12820: Shorter syntax for assigning a method argument to an instance variableRejectedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0