種類
- インスタンスメソッド (110)
- 特異メソッド (11)
ライブラリ
- ビルトイン (121)
モジュール
- Enumerable (22)
- GC (11)
キーワード
-
latest
_ gc _ info (11) - merge! (22)
- replace (11)
-
slice
_ before (22) -
to
_ hash (11) - update (22)
検索結果
先頭5件
-
Hash
# merge(*others) -> Hash (26228.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge #=> {"a"=>100, "b"=>200}
h1.merge(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1.merge(h2) {|key, oldva......0, "b"=>46, "c"=>300}
h1.merge(h2, h3) {|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.merge(bar)......# => {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo # => {1=>"a", 2=>"b", 3=>"c"}
p foo.merge!(bar) {|key, foo_val, bar_val| foo_val + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Austra... -
Hash
# merge(*others) {|key , self _ val , other _ val| . . . } -> Hash (26228.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge #=> {"a"=>100, "b"=>200}
h1.merge(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1.merge(h2) {|key, oldva......0, "b"=>46, "c"=>300}
h1.merge(h2, h3) {|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.merge(bar)......# => {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo # => {1=>"a", 2=>"b", 3=>"c"}
p foo.merge!(bar) {|key, foo_val, bar_val| foo_val + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Austra... -
Hash
# merge(other) -> Hash (26198.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge() # => {"a"=>100, "b"=>200}
h1.merge(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1.merge(h2){|key, oldval, newval| newval - oldval}
# => {"a"=>100, "b"=>54, "c"=>300}
h1 # => {"a"=>100, "b"......//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.merge(bar)
# => {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo # => {1=>"a", 2=>"b", 3=>"c"}
p foo.merge!(bar) {|key, foo_val, bar_val| foo_val + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>......a", 2=>"bB", 3=>"cC", 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin",... -
Hash
# merge(other) {|key , self _ val , other _ val| . . . } -> Hash (26198.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge() # => {"a"=>100, "b"=>200}
h1.merge(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1.merge(h2){|key, oldval, newval| newval - oldval}
# => {"a"=>100, "b"=>54, "c"=>300}
h1 # => {"a"=>100, "b"......//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.merge(bar)
# => {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo # => {1=>"a", 2=>"b", 3=>"c"}
p foo.merge!(bar) {|key, foo_val, bar_val| foo_val + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>......a", 2=>"bB", 3=>"cC", 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin",... -
Hash
# merge!(*others) -> self (14258.0) -
selfとothersのハッシュの内容を順番にマージ(統合)します。
...ます。
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1......=>100, "b"=>246, "c"=>300}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
h1......100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) {|key, v1, v2| v1 }
#=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3... -
Hash
# merge!(*others) {|key , self _ val , other _ val| . . . } -> self (14258.0) -
selfとothersのハッシュの内容を順番にマージ(統合)します。
...ます。
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1......=>100, "b"=>246, "c"=>300}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
h1......100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) {|key, v1, v2| v1 }
#=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3... -
Hash
# merge!(other) -> self (14162.0) -
selfとotherのハッシュの内容をマージ(統合)します。
...ist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #=>......{1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
p foo # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
//}
@see Hash#merge!... -
Hash
# merge!(other) {|key , self _ val , other _ val| . . . } -> self (14162.0) -
selfとotherのハッシュの内容をマージ(統合)します。
...ist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #=>......{1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
p foo # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
//}
@see Hash#merge!... -
Enumerable
# slice _ before {|elt| bool } -> Enumerator (14106.0) -
パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。
...ンクは配列として表現されます。
Enumerable#to_a や Enumerable#map のようなメソッドを使うこ
ともできます。
//emlist[例][ruby]{
# 偶数要素をチャンクの先頭と見なす
[0,2,4,1,2,4,5,3,1,4,2].slice_before(&:even?).to_a
# => [[0], [2], [4, 1], [2], [4, 5,......2].slice_before(&:odd?).to_a
# => [[0, 2, 4], [1, 2, 4], [5], [3], [1, 4, 2]]
# ChangeLog のエントリーを順に取る
open("ChangeLog") {|f|
f.slice_before(/\A\S/).each {|e| pp e}
}
# 上と同じだが、パターンでなくブロックを使う
open("ChangeLog") {|f|
f.slice_before {|......いる
IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) {|f|
f.lines.slice_before(/\AProp/).each {|lines| p lines }
}
#=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"]
# ["Properties on 'goruby.c':\n", " svn:eol-style\n"]
# ["Properties on 'complex.c':\n", " svn:mime-type\... -
Enumerable
# slice _ before(pattern) -> Enumerator (14106.0) -
パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。
...ンクは配列として表現されます。
Enumerable#to_a や Enumerable#map のようなメソッドを使うこ
ともできます。
//emlist[例][ruby]{
# 偶数要素をチャンクの先頭と見なす
[0,2,4,1,2,4,5,3,1,4,2].slice_before(&:even?).to_a
# => [[0], [2], [4, 1], [2], [4, 5,......2].slice_before(&:odd?).to_a
# => [[0, 2, 4], [1, 2, 4], [5], [3], [1, 4, 2]]
# ChangeLog のエントリーを順に取る
open("ChangeLog") {|f|
f.slice_before(/\A\S/).each {|e| pp e}
}
# 上と同じだが、パターンでなくブロックを使う
open("ChangeLog") {|f|
f.slice_before {|......いる
IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) {|f|
f.lines.slice_before(/\AProp/).each {|lines| p lines }
}
#=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"]
# ["Properties on 'goruby.c':\n", " svn:eol-style\n"]
# ["Properties on 'complex.c':\n", " svn:mime-type\... -
Hash
# update(*others) -> self (11158.0) -
selfとothersのハッシュの内容を順番にマージ(統合)します。
...ます。
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1......=>100, "b"=>246, "c"=>300}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
h1......100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) {|key, v1, v2| v1 }
#=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3... -
Hash
# update(*others) {|key , self _ val , other _ val| . . . } -> self (11158.0) -
selfとothersのハッシュの内容を順番にマージ(統合)します。
...ます。
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1......=>100, "b"=>246, "c"=>300}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
h1......100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) {|key, v1, v2| v1 }
#=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>200, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3... -
Hash
# update(other) -> self (11062.0) -
selfとotherのハッシュの内容をマージ(統合)します。
...ist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #=>......{1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
p foo # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
//}
@see Hash#merge!... -
Hash
# update(other) {|key , self _ val , other _ val| . . . } -> self (11062.0) -
selfとotherのハッシュの内容をマージ(統合)します。
...ist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #=>......{1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
p foo # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
//}
@see Hash#merge!... -
Object
# to _ hash -> Hash (11006.0) -
オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...す。
デフォルトでは定義されていません。
説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。
このメソッドを定義す......すべての場面で代置可能であるような、
* ハッシュそのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_hash
{'as' => 24}
end
end
it = Foo.new
p({:as => 12}.merge(it)) #=> {"as"=>24, :as=>12}
//}... -
GC
. latest _ gc _ info(key) -> object (8106.0) -
最新のGCの情報を返します。
...を
Symbol で指定します。
//emlist[例][ruby]{
latest = GC.latest_gc_info
latest # => {:major_by=>nil, :gc_by=>:newobj, :have_finalizer=>false, :immediate_sweep=>false, :state=>:sweeping}
stat = GC.stat
merged = GC.latest_gc_info(stat)
merged == latest.merge(stat) # => true
GC.l......atest_gc_info(:gc_by) # => :newobj
//}...