るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.066秒)
トップページ > クエリ:-[x] > クエリ:ruby[x] > クエリ:$&[x] > 種類:文書[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

検索結果

クラス/メソッドの定義 (367.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...hod
* class_method
* limit
* 定義に関する操作:
* alias
* undef
* defined

===[a:class] クラス定義

//emlist[例][ruby]{
class Foo < Super
def test
# ...
end
# ...
end
//}

文法:

class 識別子 [`<' superclass ]
式..
en...
...外処理についてはd:spec/control#begin参照。

クラス定義は、識別子で指定した定数へのクラスの代入になります
(Ruby では、クラスもオブジェクトの一つで Classクラスの
インスタンスです)。

クラスが既に定義されているとき、...
...追加になります。
ただし、元のクラスと異なるスーパークラスを指定すると TypeError が発生します。

//emlist[][ruby]{
class Foo < Array
def foo
end
end

# 定義を追加(スーパークラス Array を明示的に指定しても同じ)
class Foo
def bar...

変数と定数 (151.0)

変数と定数 * local * instance * class * class_var_scope * global * pseudo * const * prio

...変数と定数
* local
* instance
* class
* class_var_scope
* global
* pseudo
* const
* prio

Ruby
の変数と定数の種別は変数名の最初の一文字によって、
ローカル変数、
インスタンス変数、
クラス変数、
グローバル変数、
定数
のい...
...ltinを参照)。変数名
の長さにはメモリのサイズ以外の制限はありません。

===[a:local] ローカル変数

//emlist[例][ruby]{
foobar
//}

小文字または`_'で始まる識別子はローカル変数また
はメソッド呼び出しです。ローカル変数スコー...
...ます。

//emlist[][ruby]{
# (A) の部分はスコープに入らない
2.times {
p defined?(v) # (A)
v = 1 # ここ(宣言開始)から
p v # ここ(ブロックの終り)までが v のスコープ
}

# => nil
# 1
# nil <- これが nil である...