summaryrefslogtreecommitdiff
path: root/lib/prettyprint.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prettyprint.rb')
-rw-r--r--lib/prettyprint.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb
index 70b6da7924..6f2c8ea7cc 100644
--- a/lib/prettyprint.rb
+++ b/lib/prettyprint.rb
@@ -159,6 +159,19 @@ class PrettyPrint
@group_stack.last
end
+ def seplist(list, sep=nil, iter_method=:each)
+ sep ||= lambda { comma_breakable }
+ first = true
+ list.__send__(iter_method) {|*v|
+ if first
+ first = false
+ else
+ sep.call
+ end
+ yield(*v)
+ }
+ end
+
def first?
current_group.first?
end