Dmitriy Non
2018-08-19 19:33:37 UTC
It, actually, does not make sense.
`#new` is a method of class `Class` and `#initialize` is a
instance method of any class that is called whenever object is created.
So, first you create object with `MyClass.new` and than you initialize it's state with
`MyClass#initialize`. That makes perfect sense. At least, to me.
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
`#new` is a method of class `Class` and `#initialize` is a
instance method of any class that is called whenever object is created.
So, first you create object with `MyClass.new` and than you initialize it's state with
`MyClass#initialize`. That makes perfect sense. At least, to me.
For consistency and conciseness the object constructor should be renamed from initialize to simply new.
class Foo
def initialize(a)
@a = a
end
end
class Foo
def new(a)
@a = a
end
end
my_a = Foo.new("test")
Less typing, more consistent. What's not to like?
--
Cheers,
Mark A. Kolesar
Ownture
--
Windows provide a limited view. Come out into the open and embrace freedom!
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Unsubscribe: <mailto:ruby-talk-***@ruby-lang.org?subject=unsubscribe>class Foo
def initialize(a)
@a = a
end
end
class Foo
def new(a)
@a = a
end
end
my_a = Foo.new("test")
Less typing, more consistent. What's not to like?
--
Cheers,
Mark A. Kolesar
Ownture
--
Windows provide a limited view. Come out into the open and embrace freedom!
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>