ruby-changes:44802
From: nobu <ko1@a...>
Date: Wed, 23 Nov 2016 08:11:46 +0900 (JST)
Subject: [ruby-changes:44802] nobu:r56875 (trunk): Use `&.` and `||=` instead of if guards
nobu 2016-11-23 08:11:41 +0900 (Wed, 23 Nov 2016) New Revision: 56875 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56875 Log: Use `&.` and `||=` instead of if guards Modified files: trunk/lib/webrick/server.rb Index: lib/webrick/server.rb =================================================================== --- lib/webrick/server.rb (revision 56874) +++ lib/webrick/server.rb (revision 56875) @@ -312,22 +312,16 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/server.rb#L312 # Calls the callback +callback_name+ from the configuration with +args+ def call_callback(callback_name, *args) - if cb = @config[callback_name] - cb.call(*args) - end + @config[callback_name]&.call(*args) end def setup_shutdown_pipe - if !@shutdown_pipe - @shutdown_pipe = IO.pipe - end - @shutdown_pipe + return @shutdown_pipe ||= IO.pipe end def cleanup_shutdown_pipe(shutdown_pipe) @shutdown_pipe = nil - return if !shutdown_pipe - shutdown_pipe.each(&:close) + shutdown_pipe&.each(&:close) end def alarm_shutdown_pipe -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/