26件ヒット
[1-26件を表示]
(0.033秒)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 3
. 0 . 0 (4) - 制御構造 (11)
検索結果
-
NEWS for Ruby 2
. 0 . 0 (127.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...警告しなくなりました
=== 組み込みクラスの更新
* ARGF.class
* 追加: ARGF.class#codepoints, ARGF.class#each_codepoint
IO にある同名のメソッドに対応します
* Array
* 追加: Array#bsearch 二分探索します
* 非互換:
* Array#shuf......う動かない
str.each_line.with_index(1) {|line, lineno| ... } # このように each_line に置き換える
//}
* IO#lines, IO#chars, IO#codepoints, IO#bytes, ARGF#lines, ARGF#chars,
ARGF#bytes, StringIO#lines, StringIO#chars, StringIO#codepoints, StringIO#bytes,
Zlib::GzipReader......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... -
制御構造 (89.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はもっとも内側のループの次の繰り返しにジ... -
NEWS for Ruby 3
. 0 . 0 (85.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......by]{
pr = proc{|*a, **kw| [a, kw]}
pr.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]
pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}
* Arguments forwarding (`...`) now supports leading arguments.
16378
//emlist{
def method_missing(meth, .........`in` is changed to return `true` or `false`. 17371
//emlist{
0 => a
p a #=> 0
{b: 0, c: 1} => {b:}
p b #=> 0
//}
//emlist{
# version 3.0
0 in 1 #=> false
# version 2.7
0 in 1 #=> raise NoMatchingPatternError
//}
* Find-pattern is added. [EXPERIMENTAL]
16828
//emlist{
case ["a", 1, "b",...