るりまサーチ

最速Rubyリファレンスマニュアル検索!
1016件ヒット [1001-1016件を表示] (0.067秒)
トップページ > クエリ:-[x] > クエリ:Empty[x] > クエリ:empty[x]

別のキーワード

  1. _builtin empty?
  2. matrix empty
  3. set empty?
  4. dbm empty?
  5. gdbm empty?

ライブラリ

モジュール

オブジェクト

検索結果

<< < ... 9 10 11 >>

制御構造 (30.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...はその引数になります。


====[a:next] next

//emlist[例][ruby]{
# 空行を捨てるcat
ARGF.each_line do |line|
next if line.strip.empty?
print line
end
//}

文法:

next

next val


nextはもっとも内側のループの次の繰り返しにジャンプしま...
...ます。

//emlist[][ruby]{
def iter
# (a)
# :
# (b)
yield
# (c)
# :
# (d)
end
iter { redo } # -> (b) へ飛ぶ
iter { next } # -> (c) へ飛ぶ
iter { break } # -> (d) へ飛ぶ
//}

(a) は、厳密には引数評価から始まります。(b) はブロック実行の直前...
...def iter(var = p("(a)"))
yield
p "(c)"
ensure
p "(d)"
end
iter { p "(b)"; redo } # -> (a) .. (b)(b)(b)(b) ...
iter { p "(b)"; next } # -> (a) .. (b)(c) .. (d)
iter { p "(b)"; break } # -> (a)..(b)(d)
//}

====[a:retry] retry

例:

retry

文法:

retry

retr...

pp (24.0)

オブジェクトなどを見やすく出力するためのライブラリです。

...、Kernel.#pp を使う上で余計な作業をする
必要はありません。

=== どちらが読みやすいでしょうか?

p による pretty-print されてない出力:
#<PP:0x81a0d10 @stack=[], @genspace=#<Proc:0x81a0cc0>, @nest=[0], @newline="\n",
@buf=#<PrettyPrint::Group:0x81a0c9...
...end
end
first = false
}
end
q.breakable
q.text "</hash>"
end

def pretty_print_cycle(q)
q.text(empty? ? '{}' : '{...}')
end
end

h = {:a => 'a'*5, :b => 'b'*10, :c => 'c'*20, :d => 'd'*30}
pp h

#=>
# <hash>
# :d => "dddddddddd...",
# :a =>...
<< < ... 9 10 11 >>