I was wondering if there was a way to initialize this array in one line:
mulof = []
(1..1000).each {|i| mulof << i if (i % 3 == 0 || i % 5 == 0)}
Yes there is using Enumerable#select :
mulof = (1..1000).select { |i| i % 3 == 0 || i % 5 == 0 }