別のキーワード
種類
- 文書 (26)
- 特異メソッド (22)
- インスタンスメソッド (22)
クラス
- Enumerator (22)
モジュール
- Psych (22)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 3
. 0 . 0 (4) - load (11)
-
next
_ values (11) - parse (11)
- 制御構造 (11)
検索結果
先頭5件
-
Enumerator
# next -> object (18149.0) -
「次」のオブジェクトを返します。
...。
列挙が既に最後へ到達している場合は、
StopIteration 例外を発生します。このとき列挙状態は変化しません。
つまりもう一度 next を呼ぶと再び例外が発生します。
next メソッドによる外部列挙の状態は他のイテレータメソ......ッドによる
内部列挙には影響を与えません。
ただし、 IO#each_line のようにおおもとの列挙メカニズムが副作用を
伴っている場合には影響があり得ます。
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#......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... -
Enumerator
# next _ values -> Array (6215.0) -
「次」のオブジェクトを配列で返します。
...を配列で返します。
Enumerator#next とほぼ同様の挙動をします。終端まで到達した場合は
StopIteration 例外を発生させます。
このメソッドは、
yield
と
yield nil
を区別するために使えます。
next メソッドによる外部列挙の状...... IO#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......_values
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]
#... -
NEWS for Ruby 2
. 0 . 0 (138.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...警告しなくなりました
=== 組み込みクラスの更新
* ARGF.class
* 追加: ARGF.class#codepoints, ARGF.class#each_codepoint
IO にある同名のメソッドに対応します
* Array
* 追加: Array#bsearch 二分探索します
* 非互換:
* Array#shuf......似ています
* 拡張: Hash#default_proc= default proc をクリアするために nil を渡せるようになりました
* IO
* 非推奨: IO#lines, #bytes, #chars, #codepoints
* Kernel
* 追加: Kernel.#Hash という変換メソッド。Kernel.#Array, Kernel.#Float に似......or the Next Protocol Negotiation extension. Supported
with OpenSSL 1.0.1 and higher.
* OpenSSL::OPENSSL_FIPS allows client applications to detect whether OpenSSL
is FIPS-enabled. OpenSSL.fips_mode= allows turning on and off FIPS mode
manually in order to adapt to situations whe... -
NEWS for Ruby 3
. 0 . 0 (108.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Procs......# and deprecation warning
# 3.0 => a=>1}, {}]
//}
* Arguments forwarding (`...`) now supports leading arguments.
16378
//emlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end
//}
* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern match......partition
* String#reverse
* String#rjust
* String#rpartition
* String#rstrip
* String#scrub
* String#slice!
* String#slice / String#[]
* String#split
* String#squeeze
* String#strip
* String#sub
* String#succ / String#next... -
制御構造 (106.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などとは異なり)制御構造は式であ......った break により
while 式の戻り値をその値にすることもできます。
==== while 修飾子
//emlist[例][ruby]{
sleep(60) while io_not_ready?
//}
文法:
式 while 式
右辺の式を評価した値が真の間、左辺を繰り返し実行します。
左辺の......プの戻り値はその引数になります。
====[a:next] next
//emlist[例][ruby]{
# 空行を捨てるcat
ARGF.each_line do |line|
next if line.strip.empty?
print line
end
//}
文法:
next
next val
nextはもっとも内側のループの次の繰り返しにジ... -
Psych
. load(yaml , filename = nil , fallback = false) -> object (18.0) -
YAML ドキュメントを Ruby のデータ構造(オブジェクト)に変換します。
...返します。
filename はパース中に発生した例外のメッセージに用います。
@param yaml YAML ドキュメント(文字列 or IO オブジェクト)
@param filename Psych::SyntaxError 発生時にファイル名として表示する文字列。
@param fallback 引数 yaml に......rror => ex
p ex.file # => 'file.txt'
p ex.message # => "(file.txt): found character that cannot start any token while scanning for the next token at line 1 column 5"
end
//}
キーワード引数 symbolize_names に true を指定した場合はハッシュのキー
を Symbol に変換し... -
Psych
. load(yaml , filename = nil , fallback: false , symbolize _ names: false) -> object (18.0) -
YAML ドキュメントを Ruby のデータ構造(オブジェクト)に変換します。
...返します。
filename はパース中に発生した例外のメッセージに用います。
@param yaml YAML ドキュメント(文字列 or IO オブジェクト)
@param filename Psych::SyntaxError 発生時にファイル名として表示する文字列。
@param fallback 引数 yaml に......rror => ex
p ex.file # => 'file.txt'
p ex.message # => "(file.txt): found character that cannot start any token while scanning for the next token at line 1 column 5"
end
//}
キーワード引数 symbolize_names に true を指定した場合はハッシュのキー
を Symbol に変換し... -
Psych
. parse(yaml , filename = nil) -> Psych :: Nodes :: Document (18.0) -
YAML ドキュメントをパースし、YAML の AST を返します。
...メッセージに用います。
AST については Psych::Nodes を参照してください。
@param yaml YAML ドキュメント(文字列 or IO オブジェクト)
@param filename Psych::SyntaxError 発生時にファイル名として表示する文字列。
@raise Psych::SyntaxError YAML......("---\n - a\n - b") # => #<Psych::Nodes::Document:...>
begin
Psych.parse("--- `", "file.txt")
rescue Psych::SyntaxError => ex
p ex.file # => 'file.txt'
p ex.message # => "(file.txt): found character that cannot start any token while scanning for the next token at line 1 column 5"
end
//}...