[前][次][番号順一覧][スレッド一覧]

ruby-changes:15062

From: matz <ko1@a...>
Date: Mon, 15 Mar 2010 17:44:13 +0900 (JST)
Subject: [ruby-changes:15062] Ruby:r26938 (trunk): * io.c (rb_io_print): RDoc update. a patch from Daniel Kelley

matz	2010-03-15 17:43:45 +0900 (Mon, 15 Mar 2010)

  New Revision: 26938

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26938

  Log:
    * io.c (rb_io_print): RDoc update.  a patch from Daniel Kelley
      in [ruby-core:28643].

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/test/ruby/test_io.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26937)
+++ ChangeLog	(revision 26938)
@@ -1,3 +1,8 @@
+Mon Mar 15 17:28:30 2010  Yukihiro Matsumoto  <matz@r...>
+
+	* io.c (rb_io_print): RDoc update.  a patch from Daniel Kelley
+	  in [ruby-core:28643].
+
 Mon Mar 15 14:06:07 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* random.c (next_state): no initialization here.
Index: io.c
===================================================================
--- io.c	(revision 26937)
+++ io.c	(revision 26938)
@@ -5884,7 +5884,9 @@
  *     ios.print(obj, ...)     => nil
  *
  *  Writes the given object(s) to <em>ios</em>. The stream must be
- *  opened for writing. If the output record separator (<code>$\\</code>)
+ *  opened for writing. If the output field separator (<code>$,</code>)
+ *  is not <code>nil</code>, it will be inserted between each object.
+ *  If the output record separator (<code>$\\</code>)
  *  is not <code>nil</code>, it will be appended to the output. If no
  *  arguments are given, prints <code>$_</code>. Objects that aren't
  *  strings will be converted by calling their <code>to_s</code> method.
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 26937)
+++ test/ruby/test_io.rb	(revision 26938)
@@ -1396,6 +1396,23 @@
     assert_in_out_err(["-", t.path], "print while $<.gets", %w(foo bar baz), [])
   end
 
+  def test_print_separators
+    $, = ':'
+    $\ = "\n"
+    r, w = IO.pipe
+    w.print('a')
+    w.print('a','b','c')
+    w.close
+    assert_equal("a\n", r.gets)
+    assert_equal("a:b:c\n", r.gets)
+    assert_nil r.gets
+    r.close
+    
+  ensure
+    $, = nil
+    $\ = nil
+  end
+
   def test_putc
     pipe(proc do |w|
       w.putc "A"

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]