種類
- 文書 (66)
- インスタンスメソッド (55)
- モジュール関数 (44)
キーワード
- === (33)
-
at
_ exit (11) - exit (11)
- find (22)
- include? (11)
- member? (11)
- オブジェクト指向スクリプト言語 Ruby リファレンスマニュアル (11)
- クラス/メソッドの定義 (11)
- プログラム・文・式 (11)
- メソッド呼び出し(super・ブロック付き・yield) (11)
- 制御構造 (11)
- 終了処理 (11)
検索結果
先頭5件
-
制御構造 (23000.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
制御構造
条件分岐:
* if
* unless
* case
繰り返し:
* while
* until
* for
* break
* next
* redo
* retry
例外処理:
* raise
* begin
その他:
* return
* BEGIN
* END
Rubyでは(Cなどとは異なり)制御構造は式であって、何らかの値を返すものが
あります(返さないものもあります。値を返さない式を代入式の右辺に置くと
syntax error になります)。
R... -
クラス/メソッドの定義 (24.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...ットの大文字で始まる識別子です。
rescue/ensure 節を指定し、例外処理ができます。
例外処理についてはd:spec/control#begin参照。
クラス定義は、識別子で指定した定数へのクラスの代入になります
(Ruby では、クラスもオブジ......ブジェクトには引き継がれません.
rescue/ensure 節を指定し、例外処理ができます。
例外処理についてはd:spec/control#begin参照。
特異クラス定義式は、最後に評価した式の結果を返します。最後に評価した式
が値を返さない......ットの大文字
で始まる識別子です。
rescue/ensure 節を指定し、例外処理ができます。
例外処理についてはd:spec/control#begin参照。
モジュール定義は、識別子で指定した定数へのモジュールの代入になります。
Ruby では、モジ... -
Object
# ===(other) -> bool (16.0) -
case 式で使用されるメソッドです。d:spec/control#case も参照してください。
...case 式で使用されるメソッドです。d:spec/control#case も参照してください。
このメソッドは case 式での振る舞いを考慮して、
各クラスの性質に合わせて再定義すべきです。
デフォルトでは内部で Object#== を呼び出します。
w... -
メソッド呼び出し(super・ブロック付き・yield) (12.0)
-
メソッド呼び出し(super・ブロック付き・yield) * super * block * yield * block_arg * numbered_parameters * call_method
...# => 1
# 2
# 3
//}
ブロック付きメソッドの戻り値は、通常のメソッドと同様ですが、ブロックの中から
d:spec/control#break により中断された場合は nil を返します。
break に引数を指定した場合はその値がブロック付きメソッ......い)時は例外 LocalJumpError が発生します。
yield はブロック内で最後に評価した式の値を返します。また、
d:spec/control#next によりブロックの実行が中断された場合は nil
を返します。
next に引数を指定した場合はその値が yield... -
Find
. # find(*dirs) -> Enumerator (6.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...prune を使用します。この例では "/tmp/bar"
配下のファイルやディレクトリを探索しません。prune の代わりに
d:spec/control#next を使用した場合、"/tmp/bar" 自体をスキップする
だけで、その配下の探索は続行されます。
@see find(1), Fi... -
Find
. # find(*dirs) {|file| . . . } -> nil (6.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...prune を使用します。この例では "/tmp/bar"
配下のファイルやディレクトリを探索しません。prune の代わりに
d:spec/control#next を使用した場合、"/tmp/bar" 自体をスキップする
だけで、その配下の探索は続行されます。
@see find(1), Fi... -
Find
. # find(*dirs , ignore _ error: true) -> Enumerator (6.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...prune を使用します。この例では "/tmp/bar"
配下のファイルやディレクトリを探索しません。prune の代わりに
d:spec/control#next を使用した場合、"/tmp/bar" 自体をスキップする
だけで、その配下の探索は続行されます。
@see find(1), Fi... -
Find
. # find(*dirs , ignore _ error: true) {|file| . . . } -> nil (6.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...prune を使用します。この例では "/tmp/bar"
配下のファイルやディレクトリを探索しません。prune の代わりに
d:spec/control#next を使用した場合、"/tmp/bar" 自体をスキップする
だけで、その配下の探索は続行されます。
@see find(1), Fi... -
Kernel
. # at _ exit { . . . } -> Proc (6.0) -
与えられたブロックをインタプリタ終了時に実行します。
...Proc オブジェクトで返します。
//emlist[例][ruby]{
3.times do |i|
at_exit{puts "at_exit#{i}"}
end
END{puts "END"}
at_exit{puts "at_exit"}
puts "main_end"
#=> main_end
# at_exit
# END
# at_exit2
# at_exit1
# at_exit0
//}
@see d:spec/control#END,Kernel.#exit!,Kernel.#fork... -
Kernel
. # exit(status = true) -> () (6.0) -
Rubyプログラムの実行を終了します。status として整 数が与えられた場合、その値を Ruby コマンドの終了ステータスとします。 デフォルトの終了ステータスは 0(正常終了)です。
...puts "end1 with #{err.inspect}"
end
begin
puts 'start2...'
exit
ensure
puts 'end2...'
end
puts 'end' #実行されない
#=> start
# start1...
# end1 with #<SystemExit: exit>
# start2...
# end2...
#終了ステータス:0
//}
@see Kernel.#exit!,Kernel.#abort, d:spec/control#begin... -
Module
# ===(obj) -> bool (6.0) -
指定された obj が self かそのサブクラスのインスタンスであるとき真を返します。 また、obj が self をインクルードしたクラスかそのサブクラスのインスタンスである場合にも 真を返します。上記のいずれでもない場合に false を返します。
...ルの所属関係をチェックすることになります。
//emlist[例][ruby]{
str = String.new
case str
when String # String === str を評価する
p true # => true
end
//}
@param obj 任意のオブジェクト
@see Object#kind_of?, Object#instance_of?, d:spec/control#case... -
Range
# ===(obj) -> bool (6.0) -
始端と終端の中に obj があるとき、true を返します。 そうでないとき、false を返します。
...//emlist[例][ruby]{
p ('a'..'z').include? 'at' #=> false
p ('a'..'z').cover? 'at' #=> true
p ('a'..'z') === 'at' #=> true
# 2.6 以前は、=== は、include? と同じく比較できず false を返していました。
//}
@see d:spec/control#case
@see Range#include?, Range#cover?...