[#39106] What processor do you run ruby on? — "K.Sasada" <ko1@...>

 ささだです。

13 messages 2004/02/09
[#39200] Re: What processor do you run ruby on? — "K.Sasada" <ko1@...> 2004/02/17

"K.Sasada" <ko1@namikilab.tuat.ac.jp> wrote :

[#39207] Re: What processor do you run ruby on? — Isamu KOZUKA <kozuka@...> 2004/02/17

小塚@しなきゃならないテストがいっぱいだ〜....です。

[#39129] InternetExplorer ってインターフェースとして使える? — Shin-ichiro HARA <sinara@...>

原です。

34 messages 2004/02/10
[#39130] Re: InternetExplorer ってインターフェースとして使える? — Yac <yac@...> 2004/02/10

岡です。

[#39136] Re: InternetExplorer ってインターフェースとして使える? — Yac <yac@...> 2004/02/10

岡です。

[#39140] Re: InternetExplorer ってインターフェースとして使える? — arton <artonx@...> 2004/02/11

artonです。別件。

[#39144] Re: InternetExplorer ってインターフェースとして使える? — Shin-ichiro HARA <sinara@...> 2004/02/12

原です。

[#39145] Re: InternetExplorer ってインターフェースとして使える? — arton <artonx@...> 2004/02/12

artonです。

[#39146] Re: InternetExplorer ってインターフェースとして使える? — nobu.nakada@... 2004/02/12

なかだです。

[#39147] Re: InternetExplorer ってインターフェースとして使える? — arton <artonx@...> 2004/02/12

artonです。

[#39150] Re: InternetExplorer ってインターフェースとして使える? — nobu.nakada@... 2004/02/12

なかだです。

[#39151] Re: InternetExplorer ってインターフェースとして使える? — arton <artonx@...> 2004/02/12

artonです。

[#39275] DnD on win32 — Shinichiro HIDA <shinichiro@...>

飛田と申します。

21 messages 2004/02/26
[#39276] Re: DnD on win32 — たむらけんいち <sgs02516@...> 2004/02/26

たむらです。

[#39277] Re: DnD on win32 — Shinichiro HIDA <shinichiro@...> 2004/02/27

飛田です。

[#39278] Re: DnD on win32 — Itou-T15@... 2004/02/27

[#39288] 固有値、固有ベクトルの計算 — Masahiro Sato <msato@...>

19 messages 2004/02/27

[ruby-list:39216] Re: 特異メソッドでのクラス変数

From: "eclipse" <eclipse@...>
Date: 2004-02-17 23:16:52 UTC
List: ruby-list #39216
eclipseです。
まつもとさん回答ありがとうございます。

>|class << hogeB
>|  def methodB
>|    p @insVar
>|    p @@clsVar # error
>|  end
>|end
>
>で@@clsVarの所属するクラスはなんでしょう?

トップレベルでself.classするとObjectでしょうか?
つまりクラス変数はレキシカルスコープってやつですか.

ところでトップレベルで@@clsVarを定義してみたとろNameErrorは消えたのですが,
特異メソッドで参照している@@clsVarはトップレベルではないようです.
完全にレキシカルってわけでもないようですが,なぜですか?

@@clsVar = "toplevel class"
class Hoge
  @@clsVar = "Hoge class"
  def initialize
   @insVar = "Hoge instance"
  end
  def methodA
    p @insVar
    p @@clsVar
  end
end
hogeB = Hoge.new
class << hogeB
  def methodB
    p @insVar
    p @@clsVar # Hoge.@@clsVar
  end
end
hogeB.methodB

hogeC = Hoge.new
def hogeC.methodC
  p @insVar
  p @@clsVar # Hoge.@@clsVar
end
hogeC.methodC

実行結果
"Hoge instance"
tmp.rb:21: warning: class variable access from toplevel singleton method
"Hoge class"
"Hoge instance"
"Hoge class"
"Hoge instance"
"Hoge class"


In This Thread