[#35937] WeRDS (the Weekly Ruby-Doc Summary) 2002-09-13 — maili31s@... (SugHimsi == SUGIHARA Hiroshi)

すぎむし。

14 messages 2002/09/16
[#36004] WeRDS (the Weekly Ruby-Doc Summary) 2002-09-22 — maili31s@... (SugHimsi == SUGIHARA Hiroshi) 2002/09/25

すぎむし%くどいようですが、うるさければ謹慎しますので。

[#35940] 9.2 の数値が 9.199999999999999 — "Inoue" <rubyist@...1.117.ne.jp>

井上です。

16 messages 2002/09/17
[#35941] Re: 9.2 の数値が 9.199999999999999 — matz@... (Yukihiro Matsumoto) 2002/09/17

まつもと ゆきひろです

[#35942] Re: 9.2 の数値が 9.199999999999999 — Fujimaru Hiroyasu <f-hiro@...> 2002/09/17

 藤丸です。

[#35977] [ANN] Exerb 2.1.0 — Yuya Kato <yuya-ml@4th.to>

Yuyaです。

18 messages 2002/09/20
[#35978] Cookie — 金光雅夫 (KANEMITSU Masao) <masao-k@...> 2002/09/20

金光です。どもっ (_ _)

[#35979] Re: Cookie — rio-t@... 2002/09/20

こんにちは、高石です。

[#35980] Re: Cookie — 金光雅夫 (KANEMITSU Masao) <masao-k@...> 2002/09/20

金光です。どもっ。

[ruby-list:35918] Re: How to Ref brother objct

From: "Shin'ya Adzumi" <adzumi@...>
Date: 2002-09-13 10:35:39 UTC
List: ruby-list #35918
あづみです。

"Koji Matsuda" <s99937@yahoo.co.jp> wrote:
> オブジェクトの「親」もしくは「兄弟」
> を見るにはどのようにすればよいでしょうか。

全オブジェクトをチェックして、自分自身を参照しているオブジェクトを
探して…とかすればなんとかなるかもしれませんが、非常に困難だと思い
ます。

むしろ、この例だと、

class A
  def initialize
   @b = B.new(self)
   @other = "other"
  end
  attr_reader   :b
end

class B
  def initialize(parent)
    @parent = parent
  end

  def parent_instance_variable(name)
    @parent.instance_eval("@#{name}")
  end
end

A.new.b.parent_instance_variable(:other) # => "other"

とかして、親(?)の情報を覚えさす方が簡単な気がします。

# instance_eval を使うのは避けたいところですけど

ところで、こういうのって親や兄弟って言うんでしょうか?


安積伸弥
adzumi@denpa.org

In This Thread

Prev Next