Refactoring unless statement

Hey guys,

As fairly new Rubyist here – I am doing a few ruby challenges to
sharpen up my skills albeit I am having trouble refactoring an unless

Doing a full unless statement is sometimes too much. How can I refactor
the method below to use a single-line unless statement.

games = [“Super Mario Bros.”, “Contra”, “Metroid”, “Mega Man 2”]
unless games.empty?
puts “Games in your vast collection: #{games.count}”

puts “Games in your vast collection: #{games.count}” unless games.empty?

Ruby’s pretty intuitive like that.

Thanks Joel!

On Mon, Apr 1, 2013 at 12:07 AM, Anthony P. [email protected]

Another option

games.empty? or puts “Games in your vast collection: #{games.count}”