< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #8564 has been updated by phluid61 (Matthew Kerwin).
=begin
matz (Yukihiro Matsumoto) wrote:
> We need to clarify how this intervene with #initialize. Any opinion?
>
> Matz
My suggestion is that it take effect before any explicit initialize method.
Examples:
class A
attr_accessor foo: 3
def initialize
p @foo if defined? @foo
@foo = 4
end
end
p A.new.foo #=> prints 3, then 4
class B0
attr_accessor foo: 3
end
class B1 < B0
def initialize
p @foo if defined? @foo
@foo = 4
end
end
p B1.new.foo #=> prints 3, then 4
class C0
def initialize
p @foo if defined? @foo
@foo = 4
end
end
class C1 < C0
attr_accessor foo: 3
end
p C1.new.foo #=> prints 3, then 4
=end
----------------------------------------
Feature #8564: Extend Module#attr... methods
https://bugs.ruby-lang.org/issues/8564#change-40182
Author: boris_stitnicky (Boris Stitnicky)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
Extend #attr_reader, #attr_writer, #attr_accessor syntax to accept default values, such as:
attr_reader foo: 42, bar: 43
Possibility of closures evaluated at initialization time might also be considered:
attr_reader baz: -> { Time.now }, quux: 42
--
http://bugs.ruby-lang.org/