354件ヒット
[1-100件を表示]
(0.085秒)
クラス
- Array (84)
-
CSV
:: Row (27) - Date (2)
- DateTime (2)
-
Enumerator
:: Lazy (90) - PrettyPrint (1)
-
Psych
:: Handler (12) -
RubyVM
:: AbstractSyntaxTree :: Node (14) -
RubyVM
:: InstructionSequence (24) - Time (2)
モジュール
-
CGI
:: QueryExtension :: Value (24) - Enumerable (72)
キーワード
- []= (36)
- alias (12)
-
deconstruct
_ keys (9) - eager (6)
-
enum
_ for (24) - fields (12)
- first? (1)
-
first
_ column (7) -
first
_ lineno (19) - inject (24)
- last (36)
- lazy (12)
- reduce (24)
- take (12)
-
take
_ while (24) -
to
_ a (12) -
to
_ enum (24) -
values
_ at (12)
検索結果
先頭5件
-
Array
# first(n) -> Array (21235.0) -
先頭の n 要素を配列で返します。n は 0 以上でなければなりません。
...TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
@raise ArgumentError n が負値の場合発生します。
//emlist[例][ruby]{
ary = [0, 1, 2]
p ary.first(0)
p ary.first(1)
p ary.first(2)
p ary.......first(3)
p ary.first(4)
# => []
# [0]
# [0, 1]
# [0, 1, 2]
# [0, 1, 2]
//}
@see Array#last... -
Array
# first -> object | nil (21120.0) -
配列の先頭の要素を返します。要素がなければ nil を返します。
...配列の先頭の要素を返します。要素がなければ nil を返します。
//emlist[例][ruby]{
p [0, 1, 2].first #=> 0
p [].first #=> nil
//}
@see Array#last... -
CGI
:: QueryExtension :: Value # first -> self (21102.0) -
@todo
@todo -
Enumerable
# first(n) -> Array (18227.0) -
Enumerable オブジェクトの最初の要素、もしくは最初の n 要素を返します。
...引数を指定しない形式では nil を返します。
引数を指定する形式では、空の配列を返します。
@param n 取得する要素数。
//emlist[例][ruby]{
e = "abcd".each_byte
e.first #=> 97
e.first(2) #=> [97,98]
e = "".each_byte
e.first #=> nil
e.first(2) #=> []
//}... -
PrettyPrint
# first? -> bool (9114.0) -
このメソッドは obsolete です。
... first? に対する最初の呼び出しかどうかを判定する
述語です。これはカンマで区切られた値を整形するのに有用です。
pp.group(1, '[', ']') {
xxx.each {|yyy|
unless pp.first?
pp.text ','
pp.breakable
end
... pretty pr......inting yyy ...
}
}... -
RubyVM
:: InstructionSequence # first _ lineno -> Integer (9114.0) -
self が表す命令シーケンスの 1 行目の行番号を返します。
...の 1 行目の行番号を返します。
例1:irb で実行した場合
RubyVM::InstructionSequence.compile('num = 1 + 2').first_lineno
# => 1
例2:
# /tmp/method.rb
require "foo-library"
def foo
p :foo
end
RubyVM::InstructionSequence.of(method(:foo)).first_lineno
# => 2... -
RubyVM
:: AbstractSyntaxTree :: Node # first _ column -> Integer (9108.0) -
ソースコード中で、self を表すテキストが最初に現れる列番号を返します。
...ソースコード中で、self を表すテキストが最初に現れる列番号を返します。
列番号は0-originで、バイト単位で表されます。
//emlist[][ruby]{
node = RubyVM::AbstractSyntaxTree.parse('1 + 2')
p node.first_column # => 0
//}... -
RubyVM
:: AbstractSyntaxTree :: Node # first _ lineno -> Integer (9108.0) -
ソースコード中で、self を表すテキストが最初に現れる行番号を返します。
...ソースコード中で、self を表すテキストが最初に現れる行番号を返します。
行番号は1-originです。
//emlist[][ruby]{
node = RubyVM::AbstractSyntaxTree.parse('1 + 2')
p node.first_lineno # => 1
//}... -
Enumerable
# lazy -> Enumerator :: Lazy (6237.0) -
自身を lazy な Enumerator に変換したものを返します。
...自身を lazy な Enumerator に変換したものを返します。
この Enumerator は、以下のメソッドが遅延評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
*......みlazy)
* cycle (※一貫性のため、ブロックを渡さないケースのみlazy)
以下はピタゴラス数 (a**2 + b**2 = c**2 を満たす自然数 a, b, c の組) を
列挙するプログラムです。
//emlist[例][ruby]{
def pythagorean_triples
(1..Float::INFINITY).lazy.flat_ma......(x..z).select {|y|
x**2 + y**2 == z**2
}.map {|y|
[x, y, z]
}
}
}
end
# 最初の10個のピタゴラス数を表示する
p pythagorean_triples.take(10).force # takeはlazyなので、forceが必要です
p pythagorean_triples.first(10) # firstはeagerです
#... -
CSV
:: Row # deconstruct _ keys(keys) -> Hash (6213.0) -
パターンマッチに使用するヘッダの名前と値の Hash を返します。
...シンボルに変換する必要があります。
@param keys パターンマッチに使用するヘッダの名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
require "csv"
row = CSV::Row.new([:header1, :header2, :heade........, header2: 2.., header3: 2.. }
puts "all 2 or more"
in { header1: ...2, header2: 2.., header3: 2.. }
puts "first column is less than 2, and rest columns are 2 or more"
end
#=> "first column is less than 2, and rest columns are 2 or more" が出力される
//}
@see d:spec/pattern_matching#mat... -
Date
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (6119.0) -
パターンマッチに使用する名前と値の Hash を返します。
...* :year
* :month
* :day
* :yday
* :wday
@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
d = Date.new(2022, 10, 5)
if d in wday: 3, day: ..7 # d......construct_keys が使われます
puts "first Wednesday of the month"
end
#=> "first Wednesday of the month" が出力される
case d
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end
#=> "working day in month 10......" が出力される
# クラスのチェックと組み合わせて利用することもできます
if d in Date(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}
@see d:spec/pattern_matching#matching_non_primitive_objects... -
Time
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (6119.0) -
パターンマッチに使用する名前と値の Hash を返します。
...* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone
@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{......30)
if t in wday: 3, day: ..7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end
#=> "first Wednesday of the month" が出力される
case t
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{mont......h}"
end
#=> "working day in month 10" が出力される
# クラスのチェックと組み合わせて利用することもできます
if t in Time(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}
@see d:spec/pattern_matching#matching_non_primitive_objects... -
DateTime
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (6107.0) -
パターンマッチに使用する名前と値の Hash を返します。
...* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :sec_fraction
* :zone
@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
dt......dt in wday: 1..5, hour: 10..18 # deconstruct_keys が使われます
puts "Working time"
end
#=> "Working time" が出力される
case dt
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end
#=> "working day in mont......h 10" が出力される
# クラスのチェックと組み合わせて利用することもできます
if dt in DateTime(wday: 1..5, hour: 10..18, day: ..7)
puts "Working time, first week of the month"
end
//}
@see d:spec/pattern_matching#matching_non_primitive_objects... -
CGI
:: QueryExtension :: Value # last -> self (6002.0) -
@todo
@todo