るりまサーチ

最速Rubyリファレンスマニュアル検索!
354件ヒット [1-100件を表示] (0.045秒)
トップページ > クエリ:object[x] > クエリ:>[x] > クエリ:to_a[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. float >
  4. complex >
  5. module >

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Object#to_a -> Array (27232.0)

オブジェクトを配列に変換した結果を返します。 デフォルトでは定義されていません。

...のメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。

//emlist[][ruby]{
p( {'a'=>1}.to_a ) # [["a", 1]]
p ['array'].to_a # ["array"]
p nil.to_a # []
//}

@see Object#to_ary,Kernel.#Array...

Struct#to_a -> [object] (18310.0)

構造体のメンバの値を配列にいれて返します。

...て返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}

[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して...

YAML::DBM#to_a -> [[String, object]] (18303.0)

キーと値のペアを配列に変換して返します。

キーと値のペアを配列に変換して返します。

Enumerable#to_a(*args) -> [object] (15316.0)

全ての要素を含む配列を返します。

...@param args each の呼び出し時に引数として渡されます。

//emlist[例][ruby]{
(1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
{ 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]

require 'prime'
Prime.entries 10 #=> [2, 3, 5, 7]
//}...

Struct#to_a -> [object] (15311.0)

構造体のメンバの値を配列にいれて返します。

...て返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}

[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して...
...呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。

@see d:spec/pattern_matching#matching_non_primitive_objects...

絞り込み条件を変える

Object#to_ary -> Array (15219.0)

オブジェクトの Array への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...
デフォルトでは定義されていません。

説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。

このメソッドを定義する...
...すべての場面で代置可能であるような、
* 配列そのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
def to_ary
[3,4]
end
end

it = Foo.new
p([1,2] + it) #=> [1, 2, 3, 4]
//}

@see Object#to_a,Kernel.#Array...

Object#tap {|x| ... } -> self (9113.0)

self を引数としてブロックを評価し、self を返します。

..."入り込む" ことが、このメソッドの主目的です。

//emlist[][ruby]{
(1..10) .tap {|x| puts "original: #{x}" }
.to_a .tap {|x| puts "array: #{x}" }
.select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
.map {|x| x*x } .tap {|x| pu...
...目的です。

//emlist[][ruby]{
(1..10) .tap {|x| puts "original: #{x}" }
.to_a .tap {|x| puts "array: #{x}" }
.select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
.map {|x| x*x } .tap {|x| puts "squares: #{x}" }
//}

@see Object#yield_self...

Struct#values -> [object] (3210.0)

構造体のメンバの値を配列にいれて返します。

...て返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}

[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して...

Net::SMTP#rcptto_list(to_addrs) { ... } -> object (302.0)

RCPTTO コマンドを to_addrs のすべてのメールアドレスに対して送ります。

...RCPTTO コマンドを to_addrs のすべてのメールアドレスに対して送ります。

コマンドを送った後、ブロックを呼び出します。
このメソッドの返り値はブロックの返り値になります。

通常は Net::SMTP#send_message, Net::SMTP#open_message_st...
...ream で
RCPTTO が送られるため利用する必要はないはずです。

@param to_addrs 送信先メールアドレスの配列...

Regexp#match(str, pos = 0) {|m| ... } -> object | nil (244.0)

指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。

...御できます(pos のデフォルト値は 0)。

//emlist[例][ruby]{
p(/(.).(.)/.match("foobar", 3).captures) # => ["b", "r"]
p(/(.).(.)/.match("foobar", -3).captures) # => ["b", "r"]
//}

pos を指定しても MatchData#offset 等の結果
には影響しません。つまり、
//emlist[][...
...は nil を返します。

//emlist[例][ruby]{
results = []
/((.)\2)/.match("foo") {|m| results << m[0] } # => ["oo"]
/((.)\2)/.match("bar") {|m| results << m[0] } # => nil
results # => ["oo"]
//}

@param str 文字列を指定します。str との正規表現マッチを行います。

@param...
...{
reg = Regexp.new("foo")

if reg.match("foobar")
puts "match"
end
# => match

p reg.match("foobar") # => #<MatchData:0x29403fc>
p reg.match("bar") # => nil

p /(foo)(bar)(baz)/.match("foobarbaz").to_a.values_at(1,2,3) # => ["foo", "bar", "baz"]
//}

=== 便利な使いかた
正規表現にマ...

絞り込み条件を変える

<< 1 2 3 ... > >>