4 ms·
subs = {3 => "Fizz", 5 => "Buzz", 7 => "Bazz"} (1..100).map{|n| subs.keys.inject(nil) {|a,k| n % k == 0 ? (a||"")+subs[k] : a} || n.to_s} Kind of boggles t
by SeoxyS 14y ago
subs = {3 => "Fizz", 5 => "Buzz", 7 => "Bazz"}
(1..100).map{|n| subs.keys.inject(nil) {|a,k| n % k == 0 ? (a||"")+subs[k] : a} || n.to_s}
Kind of boggles the mind sometimes to realize the crappy code people will write without thinking things through.