From 7011dce58ef2dca98fd3c7b7ad42f1b0e2d86ec1 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/trunk@5625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/prettyprint.rb | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a132fe2ca..e951a08cea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Feb 6 00:48:37 2004 Tanaka Akira + + * lib/prettyprint.rb (PrettyPrint#first?): obsoleted. + Thu Feb 5 23:56:55 2004 Tanaka Akira * lib/prettyprint.rb (PrettyPrint#seplist): added. 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