48件ヒット
[1-48件を表示]
(0.223秒)
種類
- 文書 (26)
- インスタンスメソッド (22)
ライブラリ
- ビルトイン (22)
クラス
- Enumerator (22)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 3
. 0 . 0 (4) -
next
_ values (11) - 制御構造 (11)
検索結果
先頭5件
-
Enumerator
# next -> object (18143.0) -
「次」のオブジェクトを返します。
...化しません。
つまりもう一度 next を呼ぶと再び例外が発生します。
next メソッドによる外部列挙の状態は他のイテレータメソッドによる
内部列挙には影響を与えません。
ただし、 IO#each_line のようにおおもとの列挙メカニ......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
//}... -
Enumerator
# next _ values -> Array (6209.0) -
「次」のオブジェクトを配列で返します。
...を配列で返します。
Enumerator#next とほぼ同様の挙動をします。終端まで到達した場合は
StopIteration 例外を発生させます。
このメソッドは、
yield
と
yield nil
を区別するために使えます。
next メソッドによる外部列挙の状......O#each_line のようにおおもとの列挙メカニズムが副作用を
伴っている場合には影響があり得ます。
//emlist[例: next と next_values の違いを][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
yield nil
yield [1, 2]
end
e = o.to_enum
p e.next_v......alues
p e.next_values
p e.next_values
p e.next_values
p e.next_values
e = o.to_enum
p e.next
p e.next
p e.next
p e.next
p e.next
## yield args next_values next
# yield [] nil
# yield 1 [1] 1
# yield 1, 2 [1, 2] [1, 2]
# y... -
制御構造 (82.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...制御構造
条件分岐:
* if
* unless
* case
繰り返し:
* while
* until
* for
* break
* next
* redo
* retry
例外処理:
* raise
* begin
その他:
* return
* BEGIN
* END
Rubyでは(Cなどとは異なり)制御構造は式であ......プの戻り値はその引数になります。
====[a:next] next
//emlist[例][ruby]{
# 空行を捨てるcat
ARGF.each_line do |line|
next if line.strip.empty?
print line
end
//}
文法:
next
next val
nextはもっとも内側のループの次の繰り返しにジ......ャンプします。
イテレータでは、yield 呼び出しの脱出になります。
next により抜けた yield 式は nil を返します。
ただし、引数を指定した場合、yield 式の戻り値はその引数になります。
====[a:redo] redo
例:
redo
文法:... -
NEWS for Ruby 2
. 0 . 0 (24.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...str.lines.with_index(1) {|line, lineno| ... } # str.lines が配列を返すのでもう動かない
str.each_line.with_index(1) {|line, lineno| ... } # このように each_line に置き換える
//}
* IO#lines, IO#chars, IO#codepoints, IO#bytes, ARGF#lines, ARGF#chars,
ARGF#bytes,......gIO#codepoints, StringIO#bytes,
Zlib::GzipReader#lines, Zlib::GzipReader#bytes
* これらのメソッドは非推奨になりました。each_line, each_byte, each_char, each_codepoint を使ってください。
* Proc#==, m:Proc#eql?
* 削除されました。2つの Proc オブジ......exporting a
private key to PEM with a password - it has to be at least four characters
long.
* SSL/TLS support for the Next Protocol Negotiation extension. Supported
with OpenSSL 1.0.1 and higher.
* OpenSSL::OPENSSL_FIPS allows client applications to detect whether OpenSSL... -
NEWS for Ruby 3
. 0 . 0 (12.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...* String#delete_suffix
* String#downcase
* String#dump
* String#each_char
* String#each_grapheme_cluster
* String#each_line
* String#gsub
* String#ljust
* String#lstrip
* String#partition
* String#reverse
* String#rjust
* Stri......!
* String#slice / String#[]
* String#split
* String#squeeze
* String#strip
* String#sub
* String#succ / String#next
* String#swapcase
* String#tr
* String#tr_s
* String#upcase
* Symbol
* Symbol#to_proc now returns a lambda Proc. 162......This should have no impact on extension libraries, but users might experience slow compilations.
* Memory view interface [EXPERIMENTAL]
* The memory view interface is a C-API set to exchange a raw memory area, such as a numeric array or a bitmap image, between extension libraries. The extensi...