Hubert Jakubiak Hubert Jakubiak - 2 months ago 12
Ruby Question

How to make this simple method even shorter?

I have very simple method in my application. I wonder if there is way to make it even shorter.

def is_enough_words_to_play_game?
if Word.verified.size > 5
true
else
false
end
end

Answer

You can just write:

def is_enough_words_to_play_game?
  Word.verified.size > 5
end

Because Word.verified.size > 5 returns already a boolean.

Comments