るりまサーチ

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

別のキーワード

  1. cgi out
  2. cgi/core out
  3. zlib avail_out
  4. zlib avail_out=
  5. zlib total_out

ライブラリ

クラス

キーワード

検索結果

MatchData#begin(n) -> Integer | nil (18144.0)

n 番目の部分文字列先頭のオフセットを返します。

...範囲外の n を指定した場合に発生します。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.begin(0) # => 0
p $~.begin(1) # => 0
p $~.begin(2) # => 3
p $~.begin(3) # => nil
p $~.begin(4) # => `begin': index 4 out of matches (IndexError)
//}

@see MatchData#end...

Array#fetch(nth) -> object (13.0)

nth 番目の要素を返します。

...素も存在しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin

p a.fetch(10)
rescue IndexError => err
puts err #=> index 10 out of array
end

p a.fetch(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"...

Array#fetch(nth) {|nth| ... } -> object (13.0)

nth 番目の要素を返します。

...素も存在しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin

p a.fetch(10)
rescue IndexError => err
puts err #=> index 10 out of array
end

p a.fetch(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"...

Array#fetch(nth, ifnone) -> object (13.0)

nth 番目の要素を返します。

...素も存在しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin

p a.fetch(10)
rescue IndexError => err
puts err #=> index 10 out of array
end

p a.fetch(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"...

MatchData#end(n) -> Integer | nil (13.0)

n 番目の部分文字列終端のオフセットを返します。

...IndexError 範囲外の n を指定した場合に発生します。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.end(0) # => 6
p $~.end(1) # => 3
p $~.end(2) # => 6
p $~.end(3) # => nil
p $~.end(4) # => `end': index 4 out of matches (IndexError)
//}

@see MatchData#begin...

絞り込み条件を変える

StringScanner#pointer=(n) (13.0)

スキャンポインタのインデックスを n にセットします。

...ingScanner.new('test string')
p s.scan(/\w+/) # => "test"
p s.pos = 1 # => 1
p s.scan(/\w+/) # => "est"
p s.pos = 7 # => 7
p s.scan(/\w+/) # => "ring"

begin

s.pos = 20
rescue RangeError => err
puts err #=> index out of range
end
p s.pos = -4 # => -4
p s.scan(/\w+/) # => "ring"
//}...

StringScanner#pos=(n) (13.0)

スキャンポインタのインデックスを n にセットします。

...ingScanner.new('test string')
p s.scan(/\w+/) # => "test"
p s.pos = 1 # => 1
p s.scan(/\w+/) # => "est"
p s.pos = 7 # => 7
p s.scan(/\w+/) # => "ring"

begin

s.pos = 20
rescue RangeError => err
puts err #=> index out of range
end
p s.pos = -4 # => -4
p s.scan(/\w+/) # => "ring"
//}...