るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

RubyVM::InstructionSequence#to_a -> Array (44248.0)

self の情報を 14 要素の配列にして返します。

...
self
の情報を 14 要素の配列にして返します。

命令シーケンスを以下の情報で表します。

: magic

データフォーマットを示す文字列。常に
"YARVInstructionSequence/SimpleDataFormat"。

: major_version

命令シーケンスのメジャーバー...
...命令シーケンスを構成する命令とオペランドの配列の配列。


//emlist[例][ruby]{
require 'pp'

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
pp iseq.to_a
# ※ Ruby 2.5.0 での実行結果
# => ["YARVInstructionSequence/SimpleDataFormat",
# 2,
# 0,
# 1,
# {:arg_...

Array#to_a -> Array (18254.0)

self を返します。ただし、Array のサブクラスのインスタンスに対して呼ばれた時は、 自身を Array に変換したものを返します。

...
self
を返します。ただし、Array のサブクラスのインスタンスに対して呼ばれた時は、
自身を Array に変換したものを返します。

//emlist[例][ruby]{
class SubArray < Array; end
ary1 = Array([1, 2, 3, 4])
ary2 = SubArray([1, 2, 3, 4])

ary1.to_a # =>...
...[1, 2, 3, 4]
ary1.to_a.class # => Array

ary2.to_a # => [1, 2, 3, 4]
ary2.to_a.class # => Array
//}

@see Array#to_ary...

Set#to_a -> Array (18236.0)

self を配列に変換します。要素の順序は不定です。

...self を配列に変換します。要素の順序は不定です。

//emlist[][ruby]{
require 'set'
set = Set['hello', 'world']
p set.to_a # => ["hello", "world"]
//}...
...self を配列に変換します。要素の順序は不定です。

//emlist[][ruby]{
set = Set['hello', 'world']
p set.to_a # => ["hello", "world"]
//}...

Range#to_a -> Array (15278.0)

self を配列に変換します。

...
self
を配列に変換します。

@raise RangeError 終端のない Range オブジェクトを変換しようとしたときに発生します。

//emlist[例][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 # RangeError: cannot convert endless range to an array
//}...

Array#to_ary -> self (6336.0)

self をそのまま返します。

...
self
をそのまま返します。

//emlist[例][ruby]{
class SubArray < Array; end
ary1 = Array([1, 2, 3, 4])
ary2 = SubArray([1, 2, 3, 4])

ary1.to_ary # => [1, 2, 3, 4]
ary1.to_ary.class # => Array

ary2.to_ary # => [1, 2, 3, 4]
ary2.to_ary.class # => SubArray
//}

@see Array#t...

絞り込み条件を変える

Array#permutation(n = self.length) { |p| block } -> self (370.0)

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

...に発生します。

//emlist[例][ruby]{
a = [1, 2, 3]
a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1]...
...one permutation of length 0
a.permutation(4).to_a #=> [] : no permutations of length 4
//}

ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.permutation(2)...

Enumerator#each -> self (286.0)

生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。

...引数

//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"

enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"...
...# "Ruby"
# "Hacker"
//}

//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello", "world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # => ["Hel...
...:method_returned
end

enum = obj.to_enum :each_arg, :a, :x

enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned

enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # =>...

String#lines(rs = $/, chomp: false) {|line| ... } -> self (282.0)

文字列中の各行を文字列の配列で返します。(self.each_line.to_a と同じです)

...文字列中の各行を文字列の配列で返します。(self.each_line.to_a と同じです)

//emlist[][ruby]{
"aa\nbb\ncc\n".lines # => ["aa\n", "bb\n", "cc\n"]
//}

行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。
各 line には区...
...まり空行で分割します)。

chomp に true を指定すると、分割した各行の末尾から rs を取り除きます。

//emlist[][ruby]{
"hello\nworld\n".lines # => ["hello\n", "world\n"]
"hello\nworld\n".lines(chomp: true) # => ["hello", "world"]
//}

@param rs 行末...
...省略した場合は false を指定したとみなされます。

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

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

@see String#each_line...

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

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

...す。(self.each_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...
<< 1 2 3 ... > >>