るりまサーチ

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

別のキーワード

  1. _builtin each_object
  2. objectspace each_object
  3. object enum_for
  4. object to_enum
  5. object send

クラス

検索結果

Array#fetch(nth) -> object (18238.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"
999
}
p result #=> 999
//}...

Array#fetch(nth) {|nth| ... } -> object (18238.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"
999
}
p result #=> 999
//}...

Array#fetch(nth, ifnone) -> object (18238.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"
999
}
p result #=> 999
//}...