るりまサーチ

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

別のキーワード

  1. _builtin begin
  2. range begin
  3. matchdata begin
  4. arithmeticsequence begin
  5. begin

ライブラリ

クラス

キーワード

検索結果

Enumerator#next -> object (18144.0)

「次」のオブジェクトを返します。

...合は、
StopIteration 例外を発生します。このとき列挙状態は変化しません。
つまりもう一度 next を呼ぶと再び例外が発生します。

next
メソッドによる外部列挙の状態は他のイテレータメソッドによる
内部列挙には影響を与え...
...enum.next
end
# => 120
# 121
# 122
//}

//emlist[例2][ruby]{
str = "xyz"
enum = str.each_byte

begin

puts enum.next while true
rescue StopIteration
puts "iteration reached at end"
end
# => 120
# 121
# 122
# iteration reached at end
puts enum.next...
...#=> 再度 StopIteration 例外が発生
//}

//emlist[例3: Kernel.#loop は StopIteration を捕捉します。][ruby]{
str = "xyz"
enum = str.each_byte
loop do
puts enum.next
end
# => 120
# 121
# 122
//}...

StopIteration#result -> object (25.0)

この例外オブジェクトを発生させる原因となったメソッド等の返り値を返します。

...ect = Object.new
def object.each
yield :yield1
yield :yield2
:each_returned
end

enumerator = object.to_enum

p enumerator.next #=> :yield1
p enumerator.next #=> :yield2

begin

enumerator.next
rescue StopIteration => error
p error.result #=> :each_returned
end...

LocalJumpError#reason -> Symbol (19.0)

例外を発生させた原因をシンボルで返します。

...y
* :next
* :return
* :noreason

例:

def foo
proc { return 10 }
end

begin

foo.call
rescue LocalJumpError => err
p err # => #<LocalJumpError: return from block-closure>
p err.reason # => :return
p err.exit_value # => 10
end

begin

Bl...

BasicSocket#getpeereid -> [Integer, Integer] (13.0)

Unix ドメインソケットにおいて接続相手の euid と egid を 返します。

...返り値は
不定です。

require 'socket'

Socket.unix_server_loop("/tmp/sock") {|s|
begin

euid, egid = s.getpeereid

# Check the connected client is myself or not.
next
if euid != Process.uid

# do something about my resource.
ensure
s.clos...