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

ruby-changes:44805

From: kazu <ko1@a...>
Date: Wed, 23 Nov 2016 08:44:57 +0900 (JST)
Subject: [ruby-changes:44805] kazu:r56878 (trunk): Use `&.` instead of `if` and `? :`

kazu	2016-11-23 08:44:51 +0900 (Wed, 23 Nov 2016)

  New Revision: 56878

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

  Log:
    Use `&.` instead of `if` and `? :`

  Modified files:
    trunk/lib/uri/generic.rb
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 56877)
+++ lib/uri/generic.rb	(revision 56878)
@@ -207,7 +207,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L207
           "the scheme #{@scheme} does not accept registry part: #{registry} (or bad hostname?)"
       end
 
-      @scheme.freeze if @scheme
+      @scheme&.freeze
       self.set_path('') if !@path && !@opaque # (see RFC2396 Section 5.2)
       self.set_port(self.default_port) if self.default_port && !@port
     end
@@ -330,7 +330,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L330
     # see also URI::Generic.scheme=
     #
     def set_scheme(v)
-      @scheme = v ? v.downcase : v
+      @scheme = v&.downcase
     end
     protected :set_scheme
 

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

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