12件ヒット
[1-12件を表示]
(0.060秒)
別のキーワード
検索結果
先頭1件
-
Marshal フォーマット (15040.0)
-
Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。
...Marshal フォーマット
フォーマットバージョン 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......r = 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
//......baz
end
end
p Baz.baz
# => 1
File.open('testfile', 'wb') do |f|
Marshal.dump(Baz, f)
end
# 別プログラム相当にするため 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
# => uni...