るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.243秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

検索結果

Marshal フォーマット (30.0)

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

...@bar = 1
end
p 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...
...ラム相当にするため remove_const
Object.send :remove_const, :Baz

module Baz
def self.baz
@@baz
end
end
p baz = Marshal.load(File.binread('testfile'))
# => Baz
baz.baz
# => uninitialized class variable @@baz in Baz (NameError)
//}

=== Symbol

':' で始まるデータ構造になり...
...:marshal_format#Object 参照)

この形式は、Array や String のインスタンス用です。

//emlist[例][ruby]{
obj = String.new
obj.instance_eval { @foo = :bar }
p Marshal.dump(obj).unpack("x2 a ac c a c a4 aca*")
# => ["I", "\"", 0, 6, ":", 9, "@foo", ":", 8, "bar"]
//}

クラスやモ...