From 0a632f27dd1308ca6770c4740019d9276baaa631 Mon Sep 17 00:00:00 2001 From: James Walker Date: Sun, 23 Sep 2018 17:26:38 -0500 Subject: [PATCH] ruby - acronym * split -> scan much cleaner! --- ruby/acronym/acronym.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ruby/acronym/acronym.rb b/ruby/acronym/acronym.rb index 03af68d..b642277 100644 --- a/ruby/acronym/acronym.rb +++ b/ruby/acronym/acronym.rb @@ -1,9 +1,5 @@ class Acronym def self.abbreviate(long_name) - abbrev = "" - long_name.split(/[\W-]+/).each do |word| - abbrev += word[0] - end - abbrev.upcase + long_name.scan(/\b\w/).join.upcase end end