るりまサーチ

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

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. module >
  4. float >
  5. complex >

種類

ライブラリ

モジュール

キーワード

検索結果

Kernel$$DEBUG -> bool (15201.0)

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

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

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

デバッグモードでは、通常モードに比べて以下の違いがあります。

* 通常時はいずれかのスレッドが例外によって終了しても
他のスレッドは実行を続けますが、デバッグモードでは
いずれかのスレッドが例外によって終了した時に
インタプリタ全体が中断されるようになります。
Thread.abort_on_exception を
true にセットするのと同じ効果です。
* Thread.abort_on_excep...

irb (474.0)

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

...0>

あとは Ruby の式を入力するだけで、その式が実行され、結果が表示されます。

irb(main):001:0> 1+2
3
irb(main):002:0> class Foo
irb(main):003:1> def foo
irb(main):004:2> print 1
irb(main):005:2> end
irb(main):006:1> end
:foo
irb(main):007:0>...
...options:
-f ~/.irbrc を読み込まない
-m bc モード (分数と行列の計算ができる)
-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library rub...
...PT_I => nil, # 通常時のプロンプト
:PROMPT_N => nil, # 継続行のプロンプト
:PROMPT_S => nil, # 文字列などの継続行のプロンプト
:PROMPT_C => nil, # 式が継続している時のプロンプト
:RETURN => " ==>%s\n"...
...のコマンドラインオプション

irb [options] file_name opts
options:
-f ~/.irbrc を読み込まない
-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library rub...

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

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

...(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名, 行...
...(caller.first)

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

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG
= true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug in...

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

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

...(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名, 行...
...(caller.first)

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

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG
= true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug in...

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

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

...(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名, 行...
...(caller.first)

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

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG
= true

def debug(*args)
p [caller.first, *args] if $DEBUG
end

debug "debug information"

#=> ["-:7", "debug in...

絞り込み条件を変える

Kernel$$-d -> bool (101.0)

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

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

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

デバッグモードでは、通常モードに比べて以下の違いがあります。

* 通常時はいずれかのスレッドが例外によって終了しても
他のスレッドは実行を続けますが、デバッグモードでは
いずれかのスレッドが例外によって終了した時に
インタプリタ全体が中断されるようになります。
Thread.abort_on_exception を
true にセットするのと同じ効果です。
* Thread.abort_on_excep...

制御構造 (18.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...めとする制御構造をクラス設計者が定義する事が出来るものです.

=== 条件分岐
====[a:if] if

//emlist[例][ruby]{
if age >= 12 then
print "adult fee\n"
else
print "child fee\n"
end
gender = if foo.gender == "male" then "male" else "female" end
//}

文法:...
...//emlist[][ruby]{
$_ =~ リテラル
//}

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

==== if 修飾子

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

文法:

式 if 式

右辺の条件が成立する時に、左辺の式を評価してその結果を返します。
条件が成...
...り強力なパターンマッチ構文を提供しています。

//emlist[][ruby]{
case {a: 1, b: 2, c: 3}
in a: Integer => m
"matched: #{m}"
else
"not matched"
end
# => "matched: 1"
//}

パターンマッチ構文についてはspec/pattern_matchingで説明しています。

=== 繰り返...