るりまサーチ

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Object#to_a -> Array (18139.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...

Time#to_a -> Array (18121.0)

時刻を10要素の配列で返します。

...あるかどうか (true/false)
* zone: タイムゾーン (文字列)

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5)
p
t # => 2000-01-02 03:04:05 +0900
p
t.to_a # => [5, 4, 3, 2, 1, 2000, 0, 2, false, "JST"]
//}

要素の順序は C 言語の tm 構造体に合わせています。た...

Hash#to_a -> [Array] (18115.0)

キーと値からなる 2 要素の配列を並べた配列を生成して返します。

...キーと値からなる 2 要素の配列を並べた配列を生成して返します。

//emlist[例][ruby]{
h1 = { "a" => 100, 2 => ["some"], :c => "c" }
p
h1.to_a #=> c, "c"
//}

@see Hash#keys,Hash#values...

MatchData#to_a -> [String] (18115.0)

$&, $1, $2,... を格納した配列を返します。

...$&, $1, $2,... を格納した配列を返します。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p
$~.to_a # => ["foobar", "foo", "bar", nil]
//}

@see MatchData#captures...

Range#to_a -> Array (15169.0)

self を配列に変換します。

...[ruby]{
p
(5..0).to_a # => []
p
(0..3).to_a # => [0, 1, 2, 3]
p
('a'..'c').to_a # => ["a", "b", "c"]
p
(:a..:d).to_a # => [:a, :b, :c, :d]

require 'date'
p
(Date.new(1965, 4, 14) .. Date.new(1965, 4, 14)).to_a # => [#<Date: 1965-04-14 ((2438865j,0s,0n),+0s,2299161j)>]

(1..).to_a # Ra...

絞り込み条件を変える

Array#repeated_permutation(n) -> Enumerator (12227.0)

サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。

...オブジェクトを返します。

@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙...
...a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one perm...
...ロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}

@see Array#repeated_combination, Array#permutation...

Array#repeated_permutation(n) { |p| ... } -> self (12227.0)

サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。

...オブジェクトを返します。

@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙...
...a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one perm...
...ロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}

@see Array#repeated_combination, Array#permutation...

String#codepoints {|codepoint| block } -> self (6218.0)

文字列の各コードポイントの配列を返します。(self.each_codepoint.to_a と同じです)

...ch_codepoint.to_a と同じです)

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".codepoints
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
//}

ブロックが指定された場合は String#each_codepoint と同じように動作します。

Ruby 2.6 までは deprecated...
...の警告が出ますが、Ruby 2.7 で警告は削除されました。

@see String#each_codepoint...

String#grapheme_clusters {|grapheme_cluster| block } -> self (6218.0)

文字列の書記素クラスタの配列を返します。(self.each_grapheme_cluster.to_a と同じです)

...を返します。(self.each_grapheme_cluster.to_a と同じです)

//emlist[例][ruby]{
"a\u0300".grapheme_clusters # => ["à"]
//}

ブロックが指定された場合は String#each_grapheme_cluster と同じように動作します。

Ruby 2.6 までは deprecated の警告が出ますが、...
...Ruby 2.7 で警告は削除されました。

@see String#each_grapheme_cluster...

String#each_codepoint {|codepoint| block } -> self (6214.0)

文字列の各コードポイントに対して繰り返します。

...ます。

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}

@see String#codepoints...

絞り込み条件を変える

<< 1 2 3 ... > >>