るりまサーチ

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

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object to_enum
  5. object enum_for

検索結果

<< 1 2 3 > >>

Kernel.#eval(expr, bind, fname = "(eval)", lineno = 1) -> object (18377.0)

文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。

...列を評価します。

expr の中のローカル変数の扱いはブロックの場合と同じです。すなわち、eval
実行前に補足されていた変数は eval 実行後にブロック外に持ち出せます。

fname と lineno が与えられた場合には、ファイル
fname...
...きます。

bind によらずに特定のオブジェクトのコンテキストで expr を評価したい場合、
Module#module_eval, BasicObject#instance_eval が使えます。

@param expr 評価する文字列です。
@param bind 評価コンテキストです。
@param fname スタッ...
...= nil
eval
('a = RUBY_RELEASE_DATE')
p a #=> "2007-03-13"

eval
('def fuga;p 777 end')
fuga #=> 777

eval
('raise RuntimeError', binding, 'XXX.rb', 4)
#=> XXX.rb:4: RuntimeError (RuntimeError)
# from ..:9
//}

@see Kernel.#binding,Module#module_eval,BasicObject#instance_eval,Object#method,Object#...

Kernel.#eval(expr) -> object (18277.0)

文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。

...列を評価します。

expr の中のローカル変数の扱いはブロックの場合と同じです。すなわち、eval
実行前に補足されていた変数は eval 実行後にブロック外に持ち出せます。

fname と lineno が与えられた場合には、ファイル
fname...
...きます。

bind によらずに特定のオブジェクトのコンテキストで expr を評価したい場合、
Module#module_eval, BasicObject#instance_eval が使えます。

@param expr 評価する文字列です。
@param bind 評価コンテキストです。
@param fname スタッ...
...= nil
eval
('a = RUBY_RELEASE_DATE')
p a #=> "2007-03-13"

eval
('def fuga;p 777 end')
fuga #=> 777

eval
('raise RuntimeError', binding, 'XXX.rb', 4)
#=> XXX.rb:4: RuntimeError (RuntimeError)
# from ..:9
//}

@see Kernel.#binding,Module#module_eval,BasicObject#instance_eval,Object#method,Object#...

Object#instance_variables -> [Symbol] (9024.0)

オブジェクトのインスタンス変数名をシンボルの配列として返します。

...スタンス変数名をシンボルの配列として返します。

//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables

#=> [:@foo, :@bar]
//}

@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, M...

Ruby プログラムの実行 (3162.0)

Ruby プログラムの実行 === Ruby プログラム

...。ただし評価された本体に
式がなかった場合、あるいはすべての条件式が偽でかつ else 節もなかった
場合は nil です。

==== until
==== if 修飾子
==== unless 修飾子
==== while
==== until
==== while 修飾子
==== until 修飾子
==== for
==== begin 〜...
...それを評価し、その値を上位クラスとする Class
クラスのインスタンスを生成します。式が省略されていたら Object
上位クラスとします。

一方、もし同名のクラスがすでにある場合はそれを使います。そのときスーパー...
...ss を継承します。Module#module_eval/class_eval
BasicObject#instance_eval
の三つだけが例外で、以下のように変更されます。

: Module#module_eval, Module#class_eval
self、class ともそのレシーバ
: BasicObject#instance_eval
self がそのレシーバ、cla...

1.6.8から1.8.0への変更点(まとめ) (804.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...りました。
* nil: 警告を出力しない (-W0 新しい警告レベル)
* false: 重要な警告のみ出力 (-W1 デフォルト)
* true: すべての警告を出力する (-W2 or -W or -v or -w or --verbose)

追加された -W オプションは $VERBOSE = nil の指定(-W0)を...
...スは特異クラス自身であると定義されました
((<ruby-bugs-ja:313>))。なんだかよくわかりません(^^;

class << Object
p [self.id, self]
class << self
p [self.id, self]
end
end
=> ruby 1.6.7 (2002-03-01) [i5...
...END__ は、スクリプトの終りとみなさなくな
りました。((<ruby-dev:17513>))

# p "
#__END__
#"
p eval(%Q(p "\n__END__\n"))

: ((<?<whitespace>|リテラル/数値リテラル>)) [parser] [change]

?スペース、?改行、?TAB 等はリテラル...

絞り込み条件を変える

ruby 1.6 feature (402.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

... nil
を返すようになりました。(String#[]やString#slice と同じ結果を返すと
いうことです)

p "foo".slice!("bar") # <- 以前からこちらは nil を返していた
p "foo".slice!(5,10)

=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil
...
...r multipart form.

: 2002-04-10: Object#((<Object/remove_instance_variable>))

指定したインスタンス変数が定義されていない場合例外 NameError を起こ
すようになりました。((<ruby-bugs-ja:PR#216>))

Object
.new.instance_eval {
p remove_instance_v...
...ariable :@foo
}
=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil


=> -:2:in `remove_instance_variable': instance variable @foo not defined (NameError)
ruby 1.6.7 (2002-04-10) [i586-linux]

: 2002-04-04: Integer#((<Integer/step>))

第二引数が 1 より...

irb (222.0)

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

...nf[:DEBUG_LEVEL] = 1
IRB.conf[:ECHO] = nil
IRB.conf[:EVAL_HISTORY] = nil
IRB.conf[:HISTORY_FILE] = nil
IRB.conf[:IGNORE_EOF] = true
IRB.conf[:IGNORE_SIGINT] = true
IRB.conf[:INSPECT_MODE] = nil
IRB.conf[:IRB_NAME] = "irb"
IRB.conf[:IRB_RC] = nil
IRB.conf[:MATH_MODE] = false
IRB.c...
...onf[:PROMPT] = {....}
IRB.conf[:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = nil
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = true
IRB.conf[:VERBOSE] = true

それぞれの設定値の詳細については、IRB:...
...# サブ irb を起動
irb#1(main):001:0> x # x を表示
NameError: undefined local variable or method `x' for main:Object
from (irb#1):1:in `Kernel#binding'

起動時のインタプリタでローカル変数 x を定義しましたが、
「irb」でサブ irb...
...nf[:DEBUG_LEVEL] = 1
IRB.conf[:ECHO] = nil
IRB.conf[:EVAL_HISTORY] = nil
IRB.conf[:HISTORY_FILE] = nil
IRB.conf[:IGNORE_EOF] = true
IRB.conf[:IGNORE_SIGINT] = true
IRB.conf[:INSPECT_MODE] = nil
IRB.conf[:IRB_NAME] = "irb"
IRB.conf[:IRB_RC] = nil
IRB.conf[:PROMPT] = {....}
IRB.con...
...f[:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = nil
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = true
IRB.conf[:VERBOSE] = true

それぞれの設定値の詳細については、IRB::Context を参照してくだ...
...:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = true
IRB.conf[:VERBOSE] = true

それぞれの設定値の詳細については、IRB::Context を参照してくだ...

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

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

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

===[a:class] ク...
...た式の結果を返します。最後に評価した式
が値を返さない場合は nil を返します。

===[a:singleton_class] 特異クラス定義

//emlist[例][ruby]{
obj = Object.new # obj = nil でも可
class << obj
def test
# ...
end
# ...
end
//}

文法:

class...
...義したメソッドや定数は指定した
オブジェクトに対してだけ有効になります。
Object
#clone で生成したオブジェクトには引き継がれますが,
Object
#dup で生成したオブジェクトには引き継がれません.

rescue/ensure 節を指定し、...

ruby 1.8.4 feature (150.0)

ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。

...[i686-linux]
-:1: empty symbol literal

: Symbol [bug]

#Sat Oct 22 13:26:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
#
# * object.c (sym_inspect), parse.y (parser_yylex, rb_symname_p): check
# if valid as a symbol name more strictly. [ruby-dev:27478]
#
# * tes...
...:bar?

4) :$- always treats next character literally:

p eval(":$-\n") # => :"$-\n"
p :$-( # => :"$-("
p :$- # => :"$- "
p :$-#.object_id # => 3950350

# => ruby 1.8.3 (2005-09-21) [i686-linux]
:"$...
...z]+x[0-9]+$/ =~ "hogex111")
p(/^[\x61-\x7a]+x[0-9]+$/ =~ "hogex111")

# => ruby 1.8.3 (2005-09-21) [i686-linux]
0
nil

# => ruby 1.8.4 (2005-12-22) [i686-linux]
0
0

: シグナル [bug]

#Sun Oct 16 03:38:07 2005 Yukihiro M...

Marshal フォーマット (132.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...l フォーマット
フォーマットバージョン 4.8 を元に記述しています。

=== nil, true, false

それぞれ、'0', 'T', 'F' になります。

//emlist[][ruby]{
p Marshal.dump(nil).unpack1("x2 a*") # => "0"
p Marshal.dump(true).unpack1("x2 a*") # => "T"
p Marshal.dump(false...
...":", 9, "@foo", "F"]
//}

==== その他

実装上内部構造が異なるため、上記以外では、'o' になります。
(d:marshal_format#Object 参照)

//emlist[例][ruby]{
class Foo
end
p Marshal.dump(Foo.new).unpack("x2 a a c a*")
# => ["o", ":", 8, "Foo\x00"]
//}

=== 'u'

_dump、_loa...
...Bar.instance_eval { @bar } # => 1
File.open('testfile', 'wb') do |f|
Marshal.dump(Bar, f)
end

# 別プログラム相当にするため remove_const
Object
.send :remove_const, :Bar

module Bar
end

p bar = Marshal.load(File.binread('testfile'))
p bar.instance_eval { @bar }
# => nil
//}

//emlist...

絞り込み条件を変える

<< 1 2 3 > >>