From c5b3196ed4471b92e8602e026c05c630d38df8c7 Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 5 Feb 2004 15:50:43 +0000 Subject: * lib/prettyprint.rb (PrettyPrint#first?): obsoleted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/prettyprint.rb | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'lib/prettyprint.rb') diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb index 6f2c8ea7cc..25e24f6618 100644 --- a/lib/prettyprint.rb +++ b/lib/prettyprint.rb @@ -94,8 +94,36 @@ non-string formatting, etc. --- flush outputs buffered data. +--- seplist(list[, separator_proc[, iter_method]]) {|elt| ... } + adds a separated list. + The list is separated by comma with breakable space, by default. + + seplist iterates the ((|list|)) using ((|iter_method|)). + It yields each object to the block given for seplist. + The procedure ((|separator_proc|)) is called between each yields. + + If the iteration is zero times, ((|separator_proc|)) is not called at all. + + If ((|separator_proc|)) is nil or not given, + (({lambda { comma_breakable }})) is used. + If ((|iter_method|)) is not given, (({:each})) is used. + + For example, following 3 code fragments has similar effect. + + q.seplist([1,2,3]) {|v| xxx v } + + q.seplist([1,2,3], lambda { comma_breakable }, :each) {|v| xxx v } + + xxx 1 + q.comma_breakable + xxx 2 + q.comma_breakable + xxx 3 + --- first? - is a predicate to test the call is a first call to (({first?})) with + first? is obsoleted at 1.8.2. + + first? is a predicate to test the call is a first call to (({first?})) with current group. It is useful to format comma separated values as: @@ -114,10 +142,10 @@ non-string formatting, etc. == References Christian Lindig, Strictly Pretty, March 2000, -(()) +(()) Philip Wadler, A prettier printer, March 1998, -(()) +(()) == AUTHOR Tanaka Akira @@ -173,6 +201,7 @@ class PrettyPrint end def first? + warn "PrettyPrint#first? is obsoleted at 1.8.2." current_group.first? end -- cgit v1.2.3