るりまサーチ

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

別のキーワード

  1. psych psych_y
  2. psych y
  3. kernel y
  4. kernel psych_y
  5. y

ライブラリ

キーワード

検索結果

Gem::Specification.array_attributes -> Array (6107.0)

@@array_attributes の複製を返します。

...@@array_attributes の複製を返します。

@see Object#dup...

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

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

...指定された配列 ary を複製して返します。
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...

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

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

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

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

例1:Proc オブジェクトを指定した場合...
...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: 0000 cont: 0...
...lus <ic:1>
0008 dup
0009 setlocal num, 0
0012 leave

例2:Method オブジェクトを指定した場合

# /tmp/method.rb
def hello
puts "hello, world"
end

puts RubyVM::InstructionSequence.disasm(method(:hello))

出力:

== disasm: <RubyVM::InstructionSequence:...

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

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

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

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

例1:Proc オブジェクトを指定した場合...
...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: 0000 cont: 0...
...lus <ic:1>
0008 dup
0009 setlocal num, 0
0012 leave

例2:Method オブジェクトを指定した場合

# /tmp/method.rb
def hello
puts "hello, world"
end

puts RubyVM::InstructionSequence.disasm(method(:hello))

出力:

== disasm: <RubyVM::InstructionSequence:...

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

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

...で指定します。

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

//emlist[例][ruby]{
ary = Array.new(3, "foo")
p ary #=> ["foo", "foo", "foo"]
ary[0].capitalize!
p ary #=> ["Foo", "Foo", "Foo"] (各要素は同一のオブジェクトである)...

絞り込み条件を変える

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

長さ 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"]
ary[0].capitalize!
p ary #=> ["Foo"...