るりまサーチ

最速Rubyリファレンスマニュアル検索!
64件ヒット [1-64件を表示] (0.057秒)
トップページ > クエリ:Ruby[x] > クエリ:ruby[x] > クエリ:b[x] > クエリ:dup[x] > 種類:特異メソッド[x]

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

オブジェクト

キーワード

検索結果

RubyVM::InstructionSequence.disassemble(body) -> String (32107.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...引数 body で指定したオブジェクトから作成した
Ruby
VM::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。

@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合...
...# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 00...
...---------------
local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1)
[ 2] num
0000 trace 1 ( 1)
0002 putobject 1
0004 putobject 2
0006 opt_plus <ic:1>
0008 dup
0009 setlocal...

RubyVM::InstructionSequence.disasm(body) -> String (29107.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...引数 body で指定したオブジェクトから作成した
Ruby
VM::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。

@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合...
...# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 00...
...---------------
local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1)
[ 2] num
0000 trace 1 ( 1)
0002 putobject 1
0004 putobject 2
0006 opt_plus <ic:1>
0008 dup
0009 setlocal...

ENV.clone(freeze: true) -> object (119.0)

ENV オブジェクトの複製を作成して返します。

...複製で環境変数を操作するときに deprecated 警告がでます。

テスト実行中に環境変数を退避する用途には ENV.to_h を使用してください。

//emlist[][ruby]{
saved_env = ENV.to_h
# (テストなど)
ENV.replace(saved_env)
//}

@see Object#clone
@see ENV.dup...

Array.new(ary) -> Array (71.0)

指定された配列 ary を複製して返します。 Array#dup 同様 要素を複製しない浅い複製です。

...Array#dup 同様 要素を複製しない浅い複製です。

@param ary 複製したい配列を指定します。

//emlist[例][ruby]{
p Array.new([1,2,3]) # => [1,2,3]

a = ["a", "b", "c"]
b
= Array.new(a)
a.each{|s| s.capitalize! }
p a #=> ["A", "B", "C"]
p b...
...#=> ["A", "B", "C"] (b は a と要素を共有する)
//}...

Array.new(size) {|index| ... } -> Array (36.0)

長さ size の配列を生成し、各要素のインデックスを引数としてブロックを実行し、 各要素の値をブロックの評価結果に設定します。

...ます。

@param size 配列の長さを数値で指定します。

//emlist[例][ruby]{
ary = Array.new(3){|index| "hoge#{index}"}
p ary #=> ["hoge0", "hoge1", "hoge2"]
//}

//emlist[例][ruby]{
ary = Array.new(3){ "foo" }
p ary #=> ["foo", "foo", "foo"]...

絞り込み条件を変える

Array.new(size = 0, val = nil) -> Array (26.0)

長さ size の配列を生成し、各要素を val で初期化して返します。

...を指します。

@param size 配列の長さを数値で指定します。

@param val 配列の要素の値を指定します。

//emlist[例][ruby]{
ary = Array.new(3, "foo")
p ary #=> ["foo", "foo", "foo"]
ary[0].capitalize!
p ary #=> ["Foo", "Foo", "Fo...