るりまサーチ

最速Rubyリファレンスマニュアル検索!
586件ヒット [1-100件を表示] (0.047秒)
トップページ > クエリ:self[x] > クエリ:delete[x]

別のキーワード

  1. object yield_self
  2. _builtin yield_self
  3. _builtin self
  4. tracepoint self
  5. codeobject document_self

ライブラリ

クラス

オブジェクト

検索結果

<< 1 2 3 ... > >>

Set#delete(o) -> self (18246.0)

集合からオブジェクト o を削除します。

...

delete
は常に self を返します。

delete
? は、集合の要素が削除された場合には self を、変化がなかった場合
には nil を返します。

@param o 削除対象のオブジェクトを指定します。

//emlist[][ruby]{
require 'set'
s = Set[10, 20, 30]
s.delete(...
...10)
p s # => #<Set: {20, 30}>
p s.delete?(20) # => #<Set: {30}>
p s.delete?(10) # => nil
//}...

Tempfile#delete -> self (18203.0)

テンポラリファイルをクローズせずに、削除します。 UNIXライクなシステムでは、 作成したテンポラリファイルが他のプログラムに使用される機会をなくすために、 テンポラリファイルを作成しオープンした後、 すぐに削除するということがしばしばおこなわれます。

テンポラリファイルをクローズせずに、削除します。
UNIXライクなシステムでは、
作成したテンポラリファイルが他のプログラムに使用される機会をなくすために、
テンポラリファイルを作成しオープンした後、
すぐに削除するということがしばしばおこなわれます。


require "tempfile"
tf = Tempfile.new("foo")
tf.unlink
p tf.path # => nil
tf.print("foobar,hoge\n")
tf.rewind
p tf.gets("\n") # => "foobar,hoge\n"

String#delete(*strs) -> String (18135.0)

self から strs に含まれる文字を取り除いた文字列を生成して返します。

...
self
から strs に含まれる文字を取り除いた文字列を生成して返します。

str の形式は tr(1) と同じです。
つまり、`a-c' は a から c を意味し、"^0-9" のように
文字列の先頭が `^' の場合は指定文字以外を意味します。

「-」は文...
...合は、
すべての引数にマッチする文字だけが削除されます。

@param strs 削除する文字列を示す文字列 (のリスト)

//emlist[例][ruby]{
p "123456789".delete("2378") #=> "14569"
p "123456789".delete("2-8", "^4-6") #=> "14569"
//}

@see String#delete!...

REXML::Attributes#delete(attribute) -> REXML::Element (18125.0)

指定した属性を取り除きます。

...除きます。

attribute で取り除く属性を指定します。
文字列もしくは REXML::Attribute オブジェクトを指定します

self
が属する要素(REXML::Element)を返します。

@param attribute 取り除く属性(文字列もしくは REXML::Attribute オブジェクト)...
...<a foo:att='1' bar:att='2' att='&lt;'/>
</root>
EOS
a = doc.get_elements("/root/a").first

a.attributes.delete("att") # => <a foo:att='1' bar:att='2'/>
a.attributes.delete("foo:att") # => <a bar:att='2'/>
attr = a.attributes.get_attribute("bar:att")
a.attributes.delete(attr) # => <a/>
//}...

Pathname#delete -> Integer (18117.0)

self が指すディレクトリあるいはファイルを削除します。

...self が指すディレクトリあるいはファイルを削除します。

//emlist[例][ruby]{
require "pathname"

pathname = Pathname("/path/to/sample")
pathname.exist? # => true
pathname.unlink # => 1
pathname.exist? # => false
//}...

絞り込み条件を変える

Array#delete_if {|x| ... } -> self (6258.0)

要素を順番にブロックに渡して評価し、その結果が真になった要素をすべて削除します。 delete_if は常に self を返しますが、reject! は要素が 1 つ以上削除されれば self を、 1 つも削除されなければ nil を返します。

...ロックに渡して評価し、その結果が真になった要素をすべて削除します。
delete
_if は常に self を返しますが、reject! は要素が 1 つ以上削除されれば self を、
1 つも削除されなければ nil を返します。

ブロックが与えられなか...
...ッドには、
もとの配列に対して副作用があることに注意してください。

//emlist[例][ruby]{
a = [0, 1, 2, 3, 4, 5]
a.delete_if{|x| x % 2 == 0}
p a #=> [1, 3, 5]

a = [0, 1, 2, 3, 4, 5]
e = a.reject!
e.each{|i| i % 2 == 0}
p a #=> [1, 3, 5] もとの配...

Hash#delete_if {|key, value| ... } -> self (6250.0)

キーと値を引数としてブロックを評価した結果が真であ るような要素を self から削除します。

...ックを評価した結果が真であ
るような要素を self から削除します。

delete
_if は常に self を返します。
reject! は、要素を削除しなかった場合には nil を返し、
そうでなければ self を返します。

ブロックを省略した場合は Enume...
...> "4", 8 => "2" }
p h #=> { 6 => "4", 8 => "2" }

p h.delete_if{|key, value| key.to_i < value.to_i } #=> { 6 => "4", 8 => "2" }
p h.reject!{|key, value| key.to_i < value.to_i } #=> nil
//}

@see Hash#reject,Hash#delete
@see Hash#keep_if,Hash#select!...

String#delete!(*strs) -> self | nil (6248.0)

self から strs に含まれる文字を破壊的に取り除きます。

...
self
から strs に含まれる文字を破壊的に取り除きます。

str の形式は tr(1) と同じです。
つまり、「a-c」は a から c を意味し、"^0-9" のように
文字列の先頭が「^」の場合は指定文字以外を意味します。

「-」は文字列の両端...
...削除されます。

@return 通常は self を返しますが、何も変更が起こらなかった場合は nil を返します。

@param strs 削除する文字列を示す文字列 (のリスト)

//emlist[例][ruby]{
str = "123456789"
p str.delete!("2378") #=> "14569"
p str...
...#=> "14569"

str = "123456789"
p str.delete!("2-8", "^4-6") #=> "14569"
p str #=> "14569"

str = "abc"
p str.delete!("2378") #=> "nil"
p str #=> "abc"
//}

@see String#delete...

String#delete_prefix!(prefix) -> self | nil (6248.0)

self の先頭から破壊的に prefix を削除します。

...self の先頭から破壊的に prefix を削除します。

@param prefix 先頭から削除する文字列を指定します。

@return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_prefix!("hel") # => "lo"
"hello".delete_prefix!("llo") # => n...
...il
//}

@see String#delete_prefix
@see String#delete_suffix!
@see String#start_with?...

String#delete_suffix!(suffix) -> self | nil (6248.0)

self の末尾から破壊的に suffix を削除します。

...self の末尾から破壊的に suffix を削除します。

@param suffix 末尾から削除する文字列を指定します。

@return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_suffix!("llo") # => "he"
"hello".delete_suffix!("hel") # => n...
...il
//}

@see String#chomp!
@see String#chop!
@see String#delete_prefix!
@see String#delete_suffix
@see String#end_with?...

絞り込み条件を変える

<< 1 2 3 ... > >>