るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dsa p
  5. rsa p

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Array#last(n) -> Array (18168.0)

末尾の n 要素を配列で返します。n は 0 以上でなければなりません。

...上でなければなりません。

@param n 取得したい要素の個数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙...
...指定した場合に発生します。

@raise ArgumentError n が負値の場合発生します。

//emlist[例][ruby]{
ary = [0, 1, 2]
p
ary.last(0)
p
ary.last(1)
p
ary.last(2)
p
ary.last(3)
p
ary.last(4)
# => []
# [2]
# [1, 2]
# [0, 1, 2]
# [0, 1, 2]
//}

@see Array#first...

Array#last -> object | nil (18138.0)

配列の末尾の要素を返します。配列が空のときは nil を返します。

...配列の末尾の要素を返します。配列が空のときは nil を返します。

//emlist[例][ruby]{
p
[0, 1, 2].last #=> 2
p
[].last #=> nil
//}

@see Array#first...

Regexp.last_match(nth) -> String | nil (9228.0)

整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。

...(.)/ =~ "ab"
p
Regexp.last_match # => #<MatchData:0x4599e58>
p
Regexp.last_match(0) # => "ab"
p
Regexp.last_match(1) # => "a"
p
Regexp.last_match(2) # => "b"
p
Regexp.last_match(3) # => nil
//}

正規表現全体がマッチしなかった場合、引数なしの
Regexp.last_match はn...
...
last
_match[1] の形式では例外 NoMethodError が発生します。
対して、last_match(1) は nil を返します。

//emlist[例][ruby]{
str = "This is Regexp"
/That is Regexp/ =~ str
p
Regexp.last_match # => nil
begin
p
Regexp.last_match[1] # 例外が発生する
rescue
p
uts $!...
...# => undefined method `[]' for nil:NilClass
end
p
Regexp.last_match(1) # => nil
//}

@param nth 整数を指定します。
整数 nth が 0 の場合、マッチした文字列を返します。それ以外では、nth 番目の括弧にマッチした部分文字列を返します。...

Process.last_status -> Process::Status | nil (9215.0)

カレントスレッドで最後に終了した子プロセスのステータスを返します。

...じです。

P
rocess.wait Process.spawn("ruby", "-e", "exit 13")
P
rocess.last_status # => #<Process::Status: pid 4825 exit 13>

カレントスレッドで子プロセスを実行したことがない場合は nil を返します。

P
rocess.last_status # => nil

@see Process::Status
@...

Regexp.last_match -> MatchData (9183.0)

カレントスコープで最後に行った正規表現マッチの MatchData オ ブジェクトを返します。このメソッドの呼び出しは $~ の参照と同じです。

...のメソッドの呼び出しは $~
の参照と同じです。

//emlist[例][ruby]{
/(.)(.)/ =~ "ab"
p
Regexp.last_match # => #<MatchData:0x4599e58>
p
Regexp.last_match[0] # => "ab"
p
Regexp.last_match[1] # => "a"
p
Regexp.last_match[2] # => "b"
p
Regexp.last_match[3] # => nil
//}...

絞り込み条件を変える

Encoding::Converter#last_error -> Exception | nil (6239.0)

直前に変換器で発生した例外に相当する例外オブジェクトを返します。 直前の変換で例外が発生していない場合は nil を返します。

...", "iso-8859-1")
p
ec.primitive_convert(src="\xf1abcd", dst="") #=> :invalid_byte_sequence
p
ec.last_error #=> #<Encoding::InvalidByteSequenceError: "\xF1" followed by "a" on UTF-8>
p
ec.primitive_convert(src, dst, nil, 1) #=> :destination_buffer_full
p
ec.last_error #=>...

Regexp.compile(string, option = nil, code = nil) -> Regexp (6126.0)

文字列 string をコンパイルして正規表現オブジェクトを生成して返します。

...して返します。第二、第三引数は警告の上無視されます。

@param string 正規表現を文字列として与えます。

@param option Regexp::IGNORECASE, Regexp::MULTILINE,
Regexp::EXTENDED
の論理和を指定します。
Integer...
...Regexp::IGNORECASE の指定と同じになります。

@param code "n", "N" が与えられた時には、生成された正規表現のエンコーディングは ASCII-8BIT になります。
それ以外の指定は警告を出力します。

@raise RegexpError 正規表...
...is Regexp"
t1 = Regexp.compile("this is regexp", Regexp::IGNORECASE)
t1.match(str)
p
$~ # => "This is Regexp"

t2 = Regexp.compile('
this # ここは使用されない
\ is
\ regexp # ここも使用されない
', Regexp::EXTENDED | Regexp::IGNORECASE)
t2.match(str)
p
Regexp.last_match...

RubyVM::AbstractSyntaxTree::Node#last_column -> Integer (6115.0)

ソースコード中で、self を表すテキストが最後に現れる列番号を返します。

...ソースコード中で、self を表すテキストが最後に現れる列番号を返します。

列番号は0-originで、バイト単位で表されます。

//emlist[][ruby]{
node = RubyVM::AbstractSyntaxTree.parse('1 + 1')
p
node.last_column # => 5
//}...

RubyVM::AbstractSyntaxTree::Node#last_lineno -> Integer (6115.0)

ソースコード中で、self を表すテキストが最後に現れる行番号を返します。

...ソースコード中で、self を表すテキストが最後に現れる行番号を返します。

行番号は1-originです。

//emlist[][ruby]{
node = RubyVM::AbstractSyntaxTree.parse('1 + 1')
p
node.last_lineno # => 1
//}...

Enumerator::Lazy#zip(*lists) -> Enumerator::Lazy (6108.0)

Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

...Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip
同じ挙動になります。

//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #...
...<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>

1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}

@see Enumerable#zip...

絞り込み条件を変える

Enumerator::Lazy#zip(*lists) {|v1, v2, ...| ... } -> nil (6108.0)

Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

...Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip
同じ挙動になります。

//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #...
...<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>

1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}

@see Enumerable#zip...
<< 1 2 3 ... > >>