るりまサーチ

最速Rubyリファレンスマニュアル検索!
77件ヒット [1-77件を表示] (0.174秒)
トップページ > クエリ:-[x] > クエリ:e[x] > クエリ:$DEBUG[x]

別のキーワード

  1. open3 popen2e
  2. socket af_e164
  3. matrix det_e
  4. matrix rank_e
  5. open3 capture2e

種類

ライブラリ

モジュール

キーワード

検索結果

Kernel$$DEBUG -> bool (24307.0)

この値が真のときはインタプリタがデバッグモードになります。

...この値が真のときはインタプリタがデバッグモードになります。

コマンドラインオプション -d でセットされます。
スクリプトから代入することもできます。

デバッグモードでは、通常モードに比べて以下の違いがあり...
...うになります。
Thread.abort_on_exception を
true にセットするのと同じ効果です。
* Thread.abort_on_exception= の効果がなくなります。
* 例外を捕捉しているかどうかに関係なく、
例外が発生した時点で $stderr にそれが出力され...
...ます。
スクリプトの処理は続行されます。

この変数はグローバルスコープです。

@see spec/rubycmd...

Kernel.#caller(range) -> [String] | nil (9212.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...す。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得す...
...す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
e
nd

def bar
foo
e
nd

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in...
...~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
e
nd
e
nd

def foo
p parse_caller(caller.first)
e
nd

def bar
foo
p parse_caller(caller.first)
e
nd

bar
p parse_caller(caller.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の...

Kernel.#caller(start = 1) -> [String] | nil (9212.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...す。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得す...
...す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
e
nd

def bar
foo
e
nd

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in...
...~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
e
nd
e
nd

def foo
p parse_caller(caller.first)
e
nd

def bar
foo
p parse_caller(caller.first)
e
nd

bar
p parse_caller(caller.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の...

Kernel.#caller(start, length) -> [String] | nil (9212.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...す。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得す...
...す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
e
nd

def bar
foo
e
nd

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in...
...~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
e
nd
e
nd

def foo
p parse_caller(caller.first)
e
nd

def bar
foo
p parse_caller(caller.first)
e
nd

bar
p parse_caller(caller.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の...

Kernel$$-d -> bool (9107.0)

この値が真のときはインタプリタがデバッグモードになります。

...この値が真のときはインタプリタがデバッグモードになります。

コマンドラインオプション -d でセットされます。
スクリプトから代入することもできます。

デバッグモードでは、通常モードに比べて以下の違いがあり...
...うになります。
Thread.abort_on_exception を
true にセットするのと同じ効果です。
* Thread.abort_on_exception= の効果がなくなります。
* 例外を捕捉しているかどうかに関係なく、
例外が発生した時点で $stderr にそれが出力され...
...ます。
スクリプトの処理は続行されます。

この変数はグローバルスコープです。

@see spec/rubycmd...

絞り込み条件を変える

制御構造 (3042.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などとは異なり)制御構造は式であ...
...の条件式が正規表現のリテラルである時には特別に

//emlist[][ruby]{
$_ =~ リテラル
//}

であるかのように評価されます。

==== if 修飾子

//emlist[例][ruby]{
print "debug\n" if $DEBUG
//}

文法:

式 if 式

右辺の条件が成立する時に...
...呼び出しにおける break, next, redo
をまとめると以下のようになります。

//emlist[][ruby]{
def iter
# (a)
# :
# (b)
yield
# (c)
# :
# (d)
e
nd
iter { redo } # -> (b) へ飛ぶ
iter { next } # -> (c) へ飛ぶ
iter { break } # -> (d) へ飛ぶ
//}

(a) は...

irb (276.0)

irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

...irb は Interactive Ruby の略です。
irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

=== irb の使い方

Ruby さえ知っていれば irb を使うのは簡単です。
irb コマンドを実行すると、以下のようなプロン...
...しています。
readline ライブラリがインストールされている時には
自動的にコマンドライン編集や履歴の機能が使えるようになります。

=== irb のコマンドラインオプション

irb [options] file_name opts
options:
-
f ~/.ir...
...
-
m bc モード (分数と行列の計算ができる)
-
d $DEBUG を true にする (ruby -d と同じ)
-
w ruby -w と同じ
-
W[level=2] ruby -W と同じ
-
r library ruby -r と同じ
-
I ruby -I と同じ
-
U...
...
-
d $DEBUG を true にする (ruby -d と同じ)
-
w ruby -w と同じ
-
W[level=2] ruby -W と同じ
-
r library ruby -r と同じ
-
I ruby -I と同じ
-
U ruby -U と同じ
-
E enc ruby -E と同じ
-
-v...