Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > ppライブラリ > PPクラス > sharing_detection

singleton method PP.sharing_detection

sharing_detection -> bool
sharing_detection=(boolean)

共有検出フラグを表すアクセサです。 デフォルトは false です。true である場合、 PP.pp は一度出力したオブジェクトを再び出力する時 Object#pretty_print_cycle を使います。

[PARAM] boolean:
共有検出フラグを true か false で指定します。

例:

require 'pp'
b = [1, 2, 3]
a = [b, b]

pp a                        #=> [[1, 2, 3], [1, 2, 3]]

PP.sharing_detection = true
pp a                        #=> [[1, 2, 3], [...]]
class PP