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


I don't quite understand your second example.

    class Person
      initialize name: 'person', age: 18

Did you not define before that only one argument can be passed?

    class Person
      def initialize name = 'person'

By the way, I seem to be missing parts of what you are trying to
suggest.

If you mean to initialize @variables by default, similar to what
crystal does, then I think this has been suggested before. I do
not know of the current status either way, but I think that it
may be for ruby 3.x at best due to backwards compatibility (I may
be wrong here too but the ruby core team has said this a few
times before in general).

----------------------------------------
Feature #14025: #initialize with ivars
https://bugs.ruby-lang.org/issues/14025#change-67327

* Author: frankpimenta (Frank Pimenta)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
For:

  class Person
    def initialize name = 'person'
      @name = name
    end
  end

I thought that the following would be nice:

class Person
  initialize :name
 end

class Person
  initialize name: 'person', age: 18
end

class Person
  def initialize @name="person", @age=18
    puts "initializing...something to run before"
  end
end

--
 B., Frank.



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