るりまサーチ

最速Rubyリファレンスマニュアル検索!
123件ヒット [1-100件を表示] (0.062秒)

別のキーワード

  1. openssl new
  2. _builtin new
  3. rexml/document new
  4. resolv new
  5. socket new

検索結果

<< 1 2 > >>

NEWS for Ruby 2.4.0 (26072.0)

NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 2.4.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...バッファを再利用するためにオプションキーワード引数 buffer: を取るようになりました。
* Array#sum 12217
Enumerable#sum と違って each メソッドに依存しません。

* Comparable
* Comparable#clamp を追加 10594

* Dir
* Dir.empty?...
...10121

* Enumerable
* Enumerable#chunk ブロックを省略した場合 Enumerator を返すようになりました。2172
* Enumerable#sum を追加 12217
* Enumerable#uniq を追加 11090

* Enumerator::Lazy
* Enumerator::Lazy#chunk_while を追加 https://github.com/ruby/ru...

Array#sum(init=0) -> object (18196.0)

要素の合計を返します。例えば [e1, e2, e3].sum は init + e1 + e2 + e3 を返します。

...[e1, e2, e3].sum は init + e1 + e2 + e3 を返します。

ブロックが与えられた場合、加算する前に各要素にブロックが適用されます。

配列が空の場合、initを返します。

//emlist[例][ruby]{
[].sum #=> 0
[].sum(0.0)...
...0.0
[1, 2, 3].sum #=> 6
[3, 5.5].sum #=> 8.5
[2.5, 3.0].sum(0.0) {|e| e * e } #=> 15.25
[Object.new].sum #=> TypeError
//}

配列の平均値は以下のように求められます。

//emlist[例][ruby]{
mean = ary.sum(0.0) / ary.len...
...使えます。

//emlist[例][ruby]{
["a", "b", "c"].sum("") #=> "abc"
[[1], [[2]], [3]].sum([]) #=> [1, [2], 3]
//}

しかし、文字列の配列や配列の配列の場合 Array#join や Array#flatten の方が Array#sum よりも高速です。

//emlist[例][ruby]{
["a", "...

Array#sum(init=0) {|e| expr } -> object (18196.0)

要素の合計を返します。例えば [e1, e2, e3].sum は init + e1 + e2 + e3 を返します。

...[e1, e2, e3].sum は init + e1 + e2 + e3 を返します。

ブロックが与えられた場合、加算する前に各要素にブロックが適用されます。

配列が空の場合、initを返します。

//emlist[例][ruby]{
[].sum #=> 0
[].sum(0.0)...
...0.0
[1, 2, 3].sum #=> 6
[3, 5.5].sum #=> 8.5
[2.5, 3.0].sum(0.0) {|e| e * e } #=> 15.25
[Object.new].sum #=> TypeError
//}

配列の平均値は以下のように求められます。

//emlist[例][ruby]{
mean = ary.sum(0.0) / ary.len...
...使えます。

//emlist[例][ruby]{
["a", "b", "c"].sum("") #=> "abc"
[[1], [[2]], [3]].sum([]) #=> [1, [2], 3]
//}

しかし、文字列の配列や配列の配列の場合 Array#join や Array#flatten の方が Array#sum よりも高速です。

//emlist[例][ruby]{
["a", "...

OptionParser#summarize(to = [], width = self.summary_width, max = width - 1, indent= self.summary_indent) -> () (6306.0)

サマリを指定された to へと加えていきます。

...][ruby]{
require "optparse"

opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summarize(["description\n"], 10, 8, " ")
# => ["descr...

OptionParser#summarize(to = [], width = self.summary_width, max = width - 1, indent= self.summary_indent) {|line| ... } -> () (6306.0)

サマリを指定された to へと加えていきます。

...][ruby]{
require "optparse"

opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summarize(["description\n"], 10, 8, " ")
# => ["descr...

絞り込み条件を変える

Fiber#resume(*arg = nil) -> object (6106.0)

自身が表すファイバーへコンテキストを切り替えます。 自身は resume を呼んだファイバーの子となります。

...自身が表すファイバーへコンテキストを切り替えます。
自身は resume を呼んだファイバーの子となります。

ただし、Fiber#transfer を呼び出した後に resume を呼び出す事はでき
ません。

@param arg self が表すファイバーに渡した...
...が resume を
呼んだファイバーの親かその祖先である場合に発生します。
また、Fiber#transfer を呼び出した後に resume を
呼び出した場合に発生します。

//emlist[例:][ruby]{

f = Fiber.new do
Fib...
...er.yield(:hoge)
:fuga
end

p f.resume() #=> :hoge
p f.resume() #=> :fuga
p f.resume() #=> FiberError: dead fiber called
//}...

OptionParser#summary_indent -> String (6106.0)

サマリを表示する時のインデントを文字列で返します。

...s = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

opts.summary_indent # => " "
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summary_indent = " "
opts.summary_indent...
...# => " "
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
//}...

OptionParser#summary_indent=(indent) (6106.0)

サマリを表示する時のインデントを文字列で指定します。

...tionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

opts.summary_indent # => " "
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summary_indent = " " # => " "
opts.summary_indent...
...# => " "
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
//}...

OptionParser#summary_width -> Integer (6106.0)

サマリを表示するときの幅を整数で返します。

...onParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

opts.summary_width # => 32
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summary_width = 8
opts.summary_width # =>8
opts.summarize
#...

OptionParser#summary_width=(width) (6106.0)

サマリを表示するときの幅を整数で指定します。

...rser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

opts.summary_width # => 32
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summary_width = 8 # => 8
opts.summary_width # => 8
opts.summari...

絞り込み条件を変える

<< 1 2 > >>