6件ヒット
[1-6件を表示]
(0.091秒)
別のキーワード
検索結果
先頭5件
-
Set
# delete _ if {|o| . . . } -> self (18685.0) -
集合の各要素に対してブロックを実行し、その結果が真であるようなすべての 要素を削除します。
...返します。
//emlist[][ruby]{
s1 = Set['hello.rb', 'test.rb', 'hello.rb.bak']
s1.delete_if {|str| str =~ /\.bak\z/}
p s1 # => #<Set: {"hello.rb", "test.rb"}>
s2 = Set['hello.rb', 'test.rb', 'hello.rb.bak']
p s2.reject! {|str| str =~ /\.bak\z/} # => #<Set: {"hello.rb", "test.rb"}>
p s2.reject!... -
Set
# disjoint?(set) -> bool (18427.0) -
self と set が互いに素な集合である場合に true を返します。
...self と set が互いに素な集合である場合に true を返します。
逆に self と set の共通集合かを確認する場合には Set#intersect? を
使用します。
@param self Set オブジェクトを指定します。
@raise ArgumentError 引数が Set オブジェクトで......ない場合に発生します。
//emlist[][ruby]{
p Set[1, 2, 3].disjoint? Set[3, 4] # => false
p Set[1, 2, 3].disjoint? Set[4, 5] # => true
//}
@see Set#intersect?... -
Set
# reject! {|o| . . . } -> self | nil (9685.0) -
集合の各要素に対してブロックを実行し、その結果が真であるようなすべての 要素を削除します。
...返します。
//emlist[][ruby]{
s1 = Set['hello.rb', 'test.rb', 'hello.rb.bak']
s1.delete_if {|str| str =~ /\.bak\z/}
p s1 # => #<Set: {"hello.rb", "test.rb"}>
s2 = Set['hello.rb', 'test.rb', 'hello.rb.bak']
p s2.reject! {|str| str =~ /\.bak\z/} # => #<Set: {"hello.rb", "test.rb"}>
p s2.reject!... -
Set
# add?(o) -> self | nil (688.0) -
集合にオブジェクト o を加えます。
...た場合には self を、変化がなかった場合には
nil を返します。
@param o 追加対象のオブジェクトを指定します。
//emlist[][ruby]{
s = Set[1, 2]
s << 10
p s # => #<Set: {1, 2, 10}>
p s.add?(20) # => #<Set: {1, 2, 10, 20}>
p s.add?(2) # => nil
//}... -
Set
# delete?(o) -> self | nil (685.0) -
集合からオブジェクト o を削除します。
...には self を、変化がなかった場合
には nil を返します。
@param o 削除対象のオブジェクトを指定します。
//emlist[][ruby]{
s = Set[10, 20, 30]
s.delete(10)
p s # => #<Set: {20, 30}>
p s.delete?(20) # => #<Set: {30}>
p s.delete?(10) # => nil
//}... -
Set
# flatten! -> self | nil (682.0) -
集合を再帰的に平坦化します。
...rror 集合の要素として self が再帰的に現れた場合に発生
します。
//emlist[][ruby]{
s = Set[Set[1,2], 3]
p s.flatten # => #<Set: {1, 2, 3}>
p s # => #<Set: {#<Set: {1, 2}>, 3}>
s.flatten!
p s # => #<Set: {1, 2, 3}>
//}
@see Array#flatten...