From 5fe714b2169d6fd8dd6b22eeb3745cc457123a5a Mon Sep 17 00:00:00 2001 From: Mau Magnaguagno Date: Sun, 26 Nov 2023 04:07:14 -0300 Subject: [PATCH] Prefer each_char in Psych::Visitors::Visitor::ToRuby#deserialize Use safe navigation operator with each_char to remove empty strings and improve readability. --- lib/psych/visitors/to_ruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb index 8614251c..f0fda9bd 100644 --- a/lib/psych/visitors/to_ruby.rb +++ b/lib/psych/visitors/to_ruby.rb @@ -101,7 +101,7 @@ def deserialize o source = $1 options = 0 lang = nil - ($2 || '').split('').each do |option| + $2&.each_char do |option| case option when 'x' then options |= Regexp::EXTENDED when 'i' then options |= Regexp::IGNORECASE