るりまサーチ

最速Rubyリファレンスマニュアル検索!
1012件ヒット [1-100件を表示] (0.070秒)
トップページ > クエリ:|[x] > クエリ:-[x] > クエリ:last[x]

別のキーワード

  1. _builtin |
  2. set |
  3. ipaddr |
  4. nilclass |
  5. trueclass |

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Array#last -> object | nil (18320.0)

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

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

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

@see Array#first...

Enumerator::ArithmeticSequence#last -> Numeric | nil (18303.0)

等差数列の最後の要素、もしくは最後の n 要素を返します。

等差数列の最後の要素、もしくは最後の n 要素を返します。

@param n 取得する要素数。

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

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

...指定した場合に発生します。

@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...

Enumerator::ArithmeticSequence#last(n) -> [Numeric] (18203.0)

等差数列の最後の要素、もしくは最後の n 要素を返します。

等差数列の最後の要素、もしくは最後の n 要素を返します。

@param n 取得する要素数。

Regexp.last_match(nth) -> String | nil (6374.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 はnil...
...対して、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
puts $! # => undefined method `[]' for nil:NilClass
end
p Regexp.last_match(1) # =>...

絞り込み条件を変える

OpenURI::Meta#last_modified -> Time | nil (6352.0)

対象となる URI の最終更新時刻を Time オブジェクトで返します。 Last-Modified ヘッダがない場合は nil を返します。

...対象となる URI の最終更新時刻を Time オブジェクトで返します。
Last
-Modified ヘッダがない場合は nil を返します。

例:
//emlist[例][ruby]{
require 'open-uri'
open('http://www.rubyist.net/') {|f|
p f.last_modified
#=> Thu Feb 26 16:54:58 +0900 2004
}
//}...
...象となる URI の最終更新時刻を Time オブジェクトで返します。
Last
-Modified ヘッダがない場合は nil を返します。

例:
//emlist[例][ruby]{
require 'open-uri'
URI.open('http://www.rubyist.net/') {|f|
p f.last_modified
#=> Thu Feb 26 16:54:58 +0900 2004
}
//}...

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

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

...ew("utf-8", "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...

Kernel$$LAST_MATCH_INFO -> MatchData | nil (6338.0)

$~ の別名

...<a href=https://www.ruby-lang.org/en/about/license.txt>license</a>"

if /<a href=(.+?)>/ =~ str
p $LAST_MATCH_INFO[0] #=> "<a href=https://www.ruby-lang.org/en/about/license.txt>"
p $LAST_MATCH_INFO[1] #=> "https://www.ruby-lang.org/en/about/license.txt"
p $LAST_MATCH_INFO[2] #=> nil...

Kernel$$LAST_READ_LINE -> String | nil (6320.0)

$_ の別名

...$_ の別名

1 e
2 f
3 g
4 h
5 i
# end of a.txt

ruby -rEnglish -ne'p $LAST_READ_LINE' a.txt
#=>
"1 e\n"
"2 f\n"
"3 g\n"
"4 h\n"
"5 i\n"...

Kernel$$LAST_PAREN_MATCH -> String | nil (6314.0)

$+ の別名

...の別名

require "English"

r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")

while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikkou</t...

絞り込み条件を変える

<< 1 2 3 ... > >>