るりまサーチ

最速Rubyリファレンスマニュアル検索!
33件ヒット [1-33件を表示] (0.040秒)
トップページ > クエリ:array[x] > クエリ:new[x] > 種類:クラス[x]

別のキーワード

  1. array fill
  2. array []
  3. array sample
  4. array index

ライブラリ

キーワード

検索結果

Enumerator (25.0)

each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。 また、外部イテレータとしても使えます。

...モジュールは、 Module#include 先のクラスが持つ
each メソッドを元に様々なメソッドを提供します。
例えば Array#map は Array#each の繰り返しを元にして定義されます。
Enumerator を介することにより String#each_byte のような
異なる名...
...前のイテレータについても each と同様に Enumerable の機能を利用できます。

Enumerator を生成するには Enumerator.newあるいは
Object#to_enum, Object#enum_for を利用します。また、一部の
イテレータはブロックを渡さずに呼び出すと繰り...
...ります。
例えば以下のようなスレッドをまたいだ呼び出しはエラーになります。

//emlist[例][ruby]{
a = nil
Thread.new do
a = [1, 2, 3].each
a.next
end.join

p a.next
#=> t.rb:7:in `next': fiber called across threads (FiberError)
# from t.rb:7:in `<main>'
//}...

ArgumentError (19.0)

引数の数があっていないときや、数は合っていて、期待される振る舞いを持ってはいるが、期待される値ではないときに発生します。

...、数は合っていて、期待される振る舞いを持ってはいるが、期待される値ではないときに発生します。

例:

Time.at # => wrong number of arguments (0 for 1) (ArgumentError)
Array
.new(-1) # => negative array size (ArgumentError)

など

@see TypeError...
...ていて、期待される振る舞いを持ってはいるが、期待される値ではないときに発生します。

例:

Time.at # => wrong number of arguments (given 0, expected 1..2) (ArgumentError)
Array
.new(-1) # => negative array size (ArgumentError)

など

@see TypeError...

CSV (19.0)

このクラスは CSV ファイルやデータに対する完全なインターフェイスを提供します。

...<< ["another", "row"]
# ...
end
//}

=== 一行変換

//emlist[][ruby]{
require 'csv'

csv_string = ["CSV", "data"].to_csv # => "CSV,data"
csv_array = "CSV,String".parse_csv # => ["CSV", "String"]
//}

=== ショートカット

//emlist[][ruby]{
require 'csv'

CSV { |csv_out| cs...
...on)

This new CSV parser is m17n savvy. The parser works in the Encoding of the IO
or String object being read from or written to. Your data is never transcoded
(unless you ask Ruby to transcode it for you) and will literally be parsed in
the Encoding it is in. Thus CSV will return Arrays or Rows...
...is not ASCII compatible. There's no existing data for CSV to use to
prepare itself and thus you will probably need to manually specify the desired
Encoding for most of those cases. It will try to guess using the fields in a
row of output though, when using CSV::generate_line() or Array#to_csv()....