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

ruby-changes:51140

From: kazu <ko1@a...>
Date: Tue, 8 May 2018 00:07:56 +0900 (JST)
Subject: [ruby-changes:51140] kazu:r63347 (trunk): Use `&.` instead of modifier if and remove needless closed?

kazu	2018-05-08 00:07:51 +0900 (Tue, 08 May 2018)

  New Revision: 63347

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63347

  Log:
    Use `&.` instead of modifier if and remove needless closed?

  Modified files:
    trunk/test/ruby/test_io.rb
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 63346)
+++ test/ruby/test_io.rb	(revision 63347)
@@ -49,8 +49,8 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L49
     end
     flunk("timeout") unless wt.join(10) && rt.join(10)
   ensure
-    w.close unless !w || w.closed?
-    r.close unless !r || r.closed?
+    w&.close
+    r&.close
     (wt.kill; wt.join) if wt
     (rt.kill; rt.join) if rt
     raise we if we
@@ -62,8 +62,8 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L62
     begin
       yield r, w
     ensure
-      r.close unless r.closed?
-      w.close unless w.closed?
+      r.close
+      w.close
     end
   end
 
@@ -2325,7 +2325,7 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2325
       t
     end
   ensure
-    t.close(true) if t and block_given?
+    t&.close(true) if block_given?
   end
 
   def test_reopen_encoding
@@ -3160,7 +3160,7 @@ __END__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L3160
         f.ioctl(tiocgwinsz, winsize)
       }
     ensure
-      f.close if f
+      f&.close
     end
   end if /^(?:i.?86|x86_64)-linux/ =~ RUBY_PLATFORM
 

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

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